fix: preserve zero fractions when formatting integral floats - #1334
Open
rksharma-owg wants to merge 1 commit into
Open
fix: preserve zero fractions when formatting integral floats#1334rksharma-owg wants to merge 1 commit into
rksharma-owg wants to merge 1 commit into
Conversation
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.
std.format("%f", 1e20)produces"100000000000000000000.729344", even though the input is an exactly representable whole number. Multiplying that value by the requested precision introduces rounding error before the remainder is calculated.Preserve the whole value and a zero fraction when the input is integral. Non-integral inputs retain the existing rounding path. Regression tests cover large positive and negative integers, the largest safe integer, precision zero, signs, padding, and a fractional value that rounds into the next integer.
Refs #1331. This addresses its spurious
%ffractional digits; the separate exact-decimal%dconversion discrepancy remains outside this change. This is independent of #1332, which validates dynamic width and precision.Validation: the new regression failed before the fix; all 173 scripts in
test_suite/run_tests.shpass after rebuilding.git diff --checkand formatting oftest_suite/format.jsonnetpass. The stdlib formatter reports only existing differences outside the changed lines.