node.js saving large floating point numbers into mongo for searching

I've been wrestling with my limited knowledge of real programming and need some help...

From within node.js and saving into MongoDB (using the native driver) I need to index and search some long numbers.

An example:

87 / 53

On 64-bit windows calculator this is:

1.6415094339622641509433962264151

I run this in node.js:

var answer = 87 / 53;
console.log(answer);

and I get:

1.6415094339622642

my understanding is because node.js only runs 32-bit, we don't get the precision needed.

So, I plugged in the node-bigint library which wraps libgmp to do big number math using strings...

Now it is:

var bigint = require('bigint');
var top = bigint('8700000000000000000000000000000000000');
var bottom = bigint(53);
var answer = top.div(bottom);
console.log(answer.toString());

I've padded with zeros to remove the floating point (easier - I only need to compare the numbers i.e. bigger than smaller than)...

This code yields:

'164150943396226415094339622641509433'

Great - I've got more accuracy than the windows calculator : )

Problem is, this number is currently a string - I'm saving the string to Mongo and doing a query like:

{thenumber:{'$gt':'164150943396226415094339622641509433'}}

I.e. I'm comparing strings against strings. This works OK because I've padded them all the same.

The question is - is this the best way (i.e. strings) to store and search values or would converting them to 64 bit Long's be faster for indexing and searching...

If the answer is 'Use Longs they are faster' I cannot for the life of me (after lots of Googling) figure out how to turn the string above into a native Mongo Long data type (with the low bits and high bits) - please help out an out of his depth programmer : )

Follow Up:

Reading Long DataType manual for the driver it has this method:

Long.fromBits(lowBits, highBits)

So targeted question - how do I turn a string that represents a 64-bit integer into these low and high bits for the Long to save... Also - is this quicker to search than a string?

Use Long.fromString to convert a string into a MongoDB Long:

var Long = require('mongodb').Long;
var long = Long.fromString(str, 10);

Second EDIT - Actually, this is the right answer for a string containing a signed 64-bit integer. The problem is that your string of '164150943396226415094339622641509433' is too large to be stored as a 64-bit signed integer. The largest value you can use is (2^63 - 1) or 9223372036854775807.