Skip to content

Normalize long trailing decimal zero suffixes - #403

Open
perfloop-agent wants to merge 1 commit into
fastfloat:mainfrom
perfloop:perfloop-pr-open-dz12ma0n75
Open

Normalize long trailing decimal zero suffixes#403
perfloop-agent wants to merge 1 commit into
fastfloat:mainfrom
perfloop:perfloop-pr-open-dz12ma0n75

Conversation

@perfloop-agent

@perfloop-agent perfloop-agent commented Aug 4, 2026

Copy link
Copy Markdown

Summary

Long ambiguous decimals can reach the bigint comparison fallback. That path materialized trailing decimal zeros even though they add no information.

This change:

  • checks for 16 terminal zeros before it scans the full suffix;
  • trims only logical integer and fraction spans;
  • keeps the original parse metadata and scientific exponent;
  • keeps the rare reparse and full trim out of line;
  • leaves inputs below the 16-zero cutoff on the existing path.

All-zero coefficients remain unchanged. Integer zeros are trimmed only after an all-zero fraction. Public result bits, consumed pointers, and error codes stay identical.

Performance

All measurements use the public fast_float::from_chars<double> path.

workload result
0-15 terminal zeros no regression; 1192.1 ns to 1153.1 ns in the accepted run
16-63 terminal zeros 6.4% faster
64-4096 terminal zeros 48.6% faster
ordinary decimals no regression; 12.51 ns to 11.73 ns

A later repeat of the exact zero-bound 0-15 measurement was statistically undecidable because its interval crossed zero. It did not show a material regression. The production headers are unchanged from the accepted result, and an independent cross-build kept the public-path gains when benchmark layout was held constant.

Testing

  • Full CMake suite: 15/15.
  • C++20 focused tests and sanitizer tests pass.
  • AppleClang C++11, C++17, and C++20 smoke builds pass.
  • Differential public parsing matches for 60,185 char inputs, 6,208 wide-character inputs, and 25,002 float/double inputs.
  • The opt-in benchmark keeps only public from_chars modes and route verification. It has no direct internal-target benchmark.

Full verification record: https://app.perfloop.ai/t/oss/cases/case_xwm9h4yejp

Keep proof on the public from_chars path. Remove the direct digit_comp benchmark because no current claim or check uses it.

Reviewed-by: Bentley
Reviewed-by: Thompson
@tsenart
tsenart force-pushed the perfloop-pr-open-dz12ma0n75 branch from 52a1f4f to b2c714a Compare August 11, 2026 23:34
tsenart
tsenart approved these changes Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants