mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08: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
2
third_party/double-conversion/wrapper.cc
vendored
2
third_party/double-conversion/wrapper.cc
vendored
|
@ -38,7 +38,7 @@ char* DoubleToJson(char buf[128], double x) {
|
|||
static const DoubleToStringConverter kDoubleToJson(
|
||||
DoubleToStringConverter::UNIQUE_ZERO |
|
||||
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN,
|
||||
"null", "null", 'e', -6, 21, 6, 0);
|
||||
"1e5000", "null", 'e', -6, 21, 6, 0);
|
||||
kDoubleToJson.ToShortest(x, &b);
|
||||
b.Finalize();
|
||||
if (READ32LE(buf) != READ32LE("-nul")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue