mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Encode ±INFINITY as ±1e5000
The V8 behavior of encoding infinity as null doesn't make sense to me. Using ±1e5000 is better, because JSON.parse decodes it as INFINITY and the information is preserved. This could be a breaking change for some
This commit is contained in:
parent
9b6718ac99
commit
fae1c32267
3 changed files with 7 additions and 12 deletions
|
@ -22,7 +22,7 @@ assert(EncodeJson(0) == "0")
|
|||
assert(EncodeJson(0.0) == "0")
|
||||
assert(EncodeJson(3.14) == "3.14")
|
||||
assert(EncodeJson(0/0) == "null")
|
||||
assert(EncodeJson(math.huge) == "null")
|
||||
assert(EncodeJson(math.huge) == "1e5000")
|
||||
assert(EncodeJson(123.456e-789) == '0')
|
||||
assert(EncodeJson(9223372036854775807) == '9223372036854775807')
|
||||
assert(EncodeJson(-9223372036854775807 - 1) == '-9223372036854775808')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue