Repository navigation
Conversation
The parser stopped accumulating the explicit exponent once it reached 0x10000000 but kept consuming its digits. A long significand could then cancel the truncated exponent: 0.(268435455 zeros)1e2684354560 parsed as 1.0 instead of overflowing, and 1(268435456 zeros)e-2684354560 parsed as 1.0 instead of underflowing. We now stop at 2^59. The significand shifts the exponent by one per digit, far less than 2^59 for any string that fits in memory, so a larger exponent is out of range whatever the significand, and 10 * 2^59 + 9 does not overflow an int64_t.
This branch has not been deployed
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.
The decimal parser stopped accumulating the explicit exponent once it reached 0x10000000 (268435456), but kept consuming its digits. A long significand can then cancel the truncated exponent:
0.+ 268435455 zeros +1e26843545601.0, successinf,result_out_of_range1+ 268435456 zeros +e-26843545601.0, success0,result_out_of_rangeWe now stop at 2^59. The significand shifts the exponent by one per digit, far less than 2^59 for any string that fits in memory, so a larger exponent is out of range whatever the significand, and
10 * 2^59 + 9does not overflow anint64_t. The fix is a single constant.The new
double.long_exponenttest builds 256 MB inputs (skipped on 32-bit builds; about 3 seconds). Without the fix, it fails on the two inputs above.Benchmarks
Linux, Intel Xeon Gold 6548N,
realbenchmarkpinned to one core, interleaved, median of 5 runs. canada.txt and mesh.txt have no exponents: instruction counts are unchanged. On 200k random doubles printed with%.17g(all with exponents):