seq: fix -w padding for scientific notation with leading placeholder zero - #14180
Open
MadeNavaneeth wants to merge 1 commit into
Open
seq: fix -w padding for scientific notation with leading placeholder zero#14180MadeNavaneeth wants to merge 1 commit into
MadeNavaneeth wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
…zero When the mantissa has a leading placeholder zero (e.g. 0.5, -.1) and a positive exponent shifts the decimal point past that zero, the zero is no longer part of the integral representation. Previously, the code kept the counted digit and added the exponent on top, inflating the integral-digit count by one. Fix by detecting mantissas like 0.xxx or .xxx (after optional sign) that contain a non-zero fractional digit, and subtracting 1 from the integral digit count after applying the exponent. Fixes uutils#14153
MadeNavaneeth
force-pushed
the
fix/seq-width-padding
branch
from
August 27, 2026 15:30
5f95912 to
2007314
Compare
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.
Summary
Fixes
seq -wpadding width for scientific notation operands where the mantissa has a leading placeholder zero (e.g.0.5e1,-.1e2).When the mantissa starts with
0.(or-./.) and a positive exponent shifts the decimal point past that zero, the zero is no longer part of the integral representation. Previously,compute_num_digitskept the counted digit and added the exponent on top, inflating the integral-digit count by one.Problem
For
seq -w 0.5e1 0.5e1:05(padding width 2)5(padding width 1, matching GNU)For
seq -w -.1e2 10 100:-010,0000, ...0100(padding width 4)-10,000, ...100(padding width 3, matching GNU)Fix
In
compute_num_digits, after applying a positive exponent, check if the mantissa has a leading placeholder zero (0.xxx,.xxx, or-.xxx) and the fractional part contains a non-zero digit. If so, subtract 1 from the integral digit count, since the exponent shifts the decimal past the placeholder zero.The check for non-zero fractional digits ensures we don't affect cases like
0.0e15(where the zero is the actual value, not a placeholder).Tests
test_num_integral_digitsunit tests to reflect corrected countstest_width_negative_scientific_notationintegration test to match GNU behaviorFixes #14153