Commit b93a00e
fix(json): preserve the sign of -0 in the integer fast path
Fixes #4053.
parse("-0") returned +0.0 while parse("-0.0") / parse("-0e0") returned
-0.0: the safe-integer fast path in lex_number_end negated the mantissa
as an Int64 (where -0 == 0) before converting to Double. Negate after
the conversion so every spelling of negative zero keeps the IEEE-754
sign bit, per RFC 8259 number semantics. The conversion-then-negation
is exact for the whole safe-integer range.
Deterministic regression tests in lex_number_test.mbt cover every
spelling of negative zero, including values that underflow to zero
(which already preserved the sign).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent d5a4518 commit b93a00e
2 files changed
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
405 | | - | |
406 | | - | |
407 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
408 | 412 | | |
409 | 413 | | |
410 | 414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
0 commit comments