How can I perform precise arithmetic on NumberLong values in the Mongo shell? It's my understanding that Javascript only has one numeric type - number
- typically limited to 54-bit floating-point precision.
Direct arithmetic using (e.g.) standard addition shows demoting coercion to lower-precision type:
> NumberLong("123456789012345678")+NumberLong("1")
123456789012345680
> NumberLong("123456789012345678")+NumberLong("2")
123456789012345680
I can see how to extract portions of a NumberLong using string representations, but this seems inefficient and is not useful for such arithmetic operations as increment or divide.