mirror of
https://github.com/nlohmann/json.git
synced 2026-09-30 22:15:19 +00:00
The parser records where the integer digits, the fraction digits, and the exponent of a float token are. For 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 with Clinger's fast path where both operands are exact, else with the Eisel-Lemire algorithm (which needs no fallback for up to 19 digits). Both round correctly, so the values are those of parse(); other tokens and types keep the library's conversion. get<double>(), materialize(), dump(), and comparisons use it. Traversing canada.json (111,000 floats, every number converted): 0.53 -> 0.86 GB/s. Tests add tokens around the limits (19 and 20 digits, 2^53, 10^22) to the bit-for-bit comparison with parse(). Signed-off-by: Niels Lohmann <mail@nlohmann.me>