-
Type:
Question
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.4.9, 2.6.3
-
Component/s: JavaScript
-
None
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
For some reason, using parseInt or parseFloat on NumberLong gives NaN, but using arithmetic operations converts them to ints/floats without issues?
See the following:
> parseInt(NumberLong(2)) NaN > parseFloat(NumberLong(2)) NaN > NumberLong(2) + NumberLong(0) 2 <-- this is an int, not NumberLong
So this obviously works:
> parseInt(NumberLong(2) + NumberLong(0)) 2
Tested on Mongo 2.4.9 and 2.6.3. This seems like a completely illogical behaviour. This became important since PHP driver converts every number to NumberFloat.