Reading the page about the MongoDB Long Datatype - it says I create one like this:
var myLong = new Long(low, high);
Where low and high are signed 32 bit parts of the larger 64 bit number...
I have got the following number as a string using node-bigint
'164150943396226415094339622641509433'
How do I convert this 64-bit!?! string into the 32-bit low and high bits needed for the Long constructor...
Also - would an indexed Mongo $gt search be quicker with a string or the Long?
Thanks in advance - I'm out of my depth...
EDIT 1
Right - on the original (much fuzzier) thread - the answer is that this number is too big for 64 bit....
So - my question is, what is the fastest way to save and search this number in 2 parts, so the original string becomes:
'164150943396226415' and '094339622641509433'
Should I turn them into Longs (in which case what about the leading zero) or is string searching as fast / slower...
You could re-phrase the question:
In MongoDB would a Long or String be faster for:
'164150943396226415'
Thanks again....
Right!
I've been talking to my friend - he has explained all of my mis-guided assumptions...
The number '164150943396226415094339622641509433' is too big for 64-bit...
He said searching strings will always go char by char and that splitting the number into a 2 compliment pair of actual 64 bit numbers is quicker...
So, for the number above we have:
var higher = Long.fromString('1641509433962264150');
var lower = Long.fromString('94339622641509433');
And then do a:
( this.higher > that.higher ) && (this.lower > that.lower)
Sorry for asking a question that was based on my own mis-understanding : )