Repository navigation
Accept numbers with huge exponents; never wrap the exponent - #486
Merged
Merged
Conversation
Licenser
reviewed
Oct 3, 2026
Licenser
approved these changes
Oct 4, 2026
Licenser
force-pushed
the
pr/huge-exponent
branch
from
October 4, 2026 10:41
33e6faa to
aefd7f4
Compare
Licenser
enabled auto-merge (squash)
October 4, 2026 10:41
Two problems with exponents beyond 32 bits in the default (correct)
number parser:
1. Rejected valid input. Once the exponent value passed 2^32 the next
digit was an `InvalidNumber` error, so `0e99999999999`,
`1e-99999999999` and `[2e-44444044280]` failed. RFC 8259 §6 puts no
limit on the exponent; these are zero (serde_json and sonic-rs
accept them; C++ simdjson saturates the exponent instead of
failing). Now the exponent saturates and the remaining digits are
still consumed.
2. Wrong values. The exponent was passed on as `exponent as i32`, which
wraps, so exponents just below the cutoff gave wrong finite numbers:
1e4294967296 1.0 (now: error, out of range like 1e309)
1e4294967295 0.1 (now: error)
1e-4294967295 10.0 (now: 0.0)
1.5e-8589934592 1.5 (now: 0.0)
It now saturates to i32::MIN/MAX, which `f64_from_parts` already
maps to 0 or to the out-of-range error.
Test: `huge_exponent` (fails before this change).
Found by a three-way differential fuzzer (serde_json, simd-json,
sonic-rs).
…iling garbage and + after a saturated exponent
Licenser
force-pushed
the
pr/huge-exponent
branch
from
October 4, 2026 12:12
aefd7f4 to
d95e1fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: accept numbers with huge exponents, never wrap the exponent
Two problems with exponents beyond 32 bits in the default (correct)
number parser:
Rejected valid input. Once the exponent value passed 2^32 the next
digit was an
InvalidNumbererror, so0e99999999999,1e-99999999999and[2e-44444044280]failed. RFC 8259 §6 puts nolimit on the exponent; these are zero (serde_json and sonic-rs
accept them; C++ simdjson saturates the exponent instead of
failing). Now the exponent saturates and the remaining digits are
still consumed.
Wrong values. The exponent was passed on as
exponent as i32, whichwraps, so exponents just below the cutoff gave wrong finite numbers:
It now saturates to i32::MIN/MAX, which
f64_from_partsalreadymaps to 0 or to the out-of-range error.
Test:
huge_exponent(fails before this change).Testing
Each commit adds a regression test that fails before the change. The full test suite passes and
cargo fmt --checkis clean on the changed files.Found with a differential fuzzer comparing serde_json, simd-json, sonic-rs and jiter.