Repository navigation
Conversation
nlohmann
added this pull request to stack #5636
September 29, 2026 14:20
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated and/or formatted correctly, or |
nlohmann
removed this pull request from stack #5636
September 30, 2026 13:19
nlohmann
force-pushed
the
json-view/14b-view-float-layout
branch
from
September 30, 2026 13:20
921b664 to
cbd93ff
Compare
nlohmann
added this pull request to stack #5739
September 30, 2026 13:21
nlohmann
force-pushed
the
json-view/14-view-compare
branch
from
September 30, 2026 15:34
4f00cac to
adbc848
Compare
nlohmann
force-pushed
the
json-view/14b-view-float-layout
branch
3 times, most recently
from
September 30, 2026 18:06
1b49a60 to
7a97dc0
Compare
nlohmann
marked this pull request as ready for review
September 30, 2026 18:17
The parser records where the integer digits, the fraction digits, and the exponent of a float token are. For floats and doubles with at most 19 digits, the value is now read from that layout: the digits eight at a time, without scanning the token, and rounded by the library's conversion core (detail::decimal_to_float(): Clinger's fast path where both operands are exact, else the Eisel-Lemire algorithm, which needs no fallback for up to 19 digits). It rounds correctly, so the values are those of parse(); other tokens and types keep the library's conversion of the whole token. get<double>(), materialize(), dump(), and comparisons use it. Traversing canada.json (111,000 floats, every number converted): 0.95 -> 1.29 GB/s. Tests add tokens around the limits (19 and 20 digits, 2^53, 10^22, and those of float) to the bit-for-bit comparison with parse(). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
force-pushed
the
json-view/14-view-compare
branch
from
September 30, 2026 19:15
c2792eb to
b992e1f
Compare
nlohmann
force-pushed
the
json-view/14b-view-float-layout
branch
from
September 30, 2026 19:15
7a97dc0 to
ecf9df7
Compare
…t-layout Signed-off-by: Niels Lohmann <mail@nlohmann.me>
…t-layout Signed-off-by: Niels Lohmann <mail@nlohmann.me>
…t-layout Signed-off-by: Niels Lohmann <mail@nlohmann.me>
…HEAD Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
removed this pull request from stack #5739
October 6, 2026 09:26
Owner
Author
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.
Part of the stack for the zero-copy view (#5295).
Summary
While parsing, the view records where the integer digits, the fraction digits, and the exponent of a float token are. For floats and doubles with at most 19 digits, the value is now read from that layout:
decimal_to_float()from Speed up the lexer: own float parser, string scan, and \u table #5738: Clinger's fast path where both operands are exact, and Eisel-Lemire otherwise, which needs no fallback for up to 19 digits.Both round correctly, so the values are those of
parse(). Longer tokens, andlong double, keep the library's conversion of the whole token.get<double>(),materialize(),dump(), and the comparisons all use it.Benchmarks
Traversing canada.json (111,000 floats, every number converted): 0.95 → 1.29 GB/s. The baseline already includes #5738, whose converter the view uses before this PR.
Tests
Tokens around the limits (19 and 20 digits, 2^53, 10^22, underflow, and those of
float) join the bit-for-bit comparison withparse().Public API
No change.
Written by Claude Code.
🤖 Generated with Claude Code