top | item 45680181

(no title)

funcDropShadow | 4 months ago

Even if we assume that JSON numbers are JavaScript numbers. There is the problem that some large natural numbers cannot be represented in double or float although some even larger numbers can be represented. This is very bad if you use these numbers as IDs.

    scala> (Long.MaxValue-1)
    val res4: Long = 9223372036854775806
                                                                                
    scala> (Long.MaxValue-1).toDouble.toLong
    val res5: Long = 9223372036854775807
The fact that I used Scala is irrelevant here. That is true for many programming languages that 64 bit long and double types.

discuss

order

dotancohen|4 months ago

But that problem is not inherent to JSON, which is a pain text encoding of those numbers.