4 ms·
There are no integers in javascript, numbers are always represented as double. Most implementations of json respect that. The error people get are because numb
by user5994461 9y ago
There are no integers in javascript, numbers are always represented as double.
Most implementations of json respect that. The error people get are because numbers are converted from double to something else that's not equivalent. Precision is around 15 digits and the usual rounding issues are applicable.
- hanbura 9y agoJSON is not javascript, and you can write valid JSON that isn't valid javascript (using unusual line seperators) No JSON standard restricts the range of numbers (except for universally prohibiting NaN and infinity, making JSON numbers clearly not IEEE doubles). The standards warns of potential interoperability issues with numbers outside the numbers representable as double, but they do allow all numbers representable in Base 10.
- nly 9y agoYou're wrong. There isn't a JSON specification anywhere that says numerics are IEEE 754 doubles. The RFC mentions "good interoperability" can be achieved by using doubles, but does not say this MUST or even SHOULD be supported.