Skip to content

fix(numfmt):fix recision loss for large numbers in #11654#11716

Open
THEMIScale wants to merge 1 commit intouutils:mainfrom
THEMIScale:main
Open

fix(numfmt):fix recision loss for large numbers in #11654#11716
THEMIScale wants to merge 1 commit intouutils:mainfrom
THEMIScale:main

Conversation

@THEMIScale
Copy link
Copy Markdown
Contributor

Fixes #11654

  • Add numeric.rs to preserve precision for large integers
  • Modify related functions in format.rs
  • Adjust some float related test cases in format.rs
  • Large integer values are now accurate
  • Float precision remains limited by f64 and is worse than GNU
  • cargo test --features unix passes for numfmt

@THEMIScale
Copy link
Copy Markdown
Contributor Author

There's a remaining problem here:

┌──(kali㉿KaliOnHP)-[~/coreutils]
└─$ ./target/debug/numfmt --from=iec 915339622.7555392131
915339622.7555391788

┌──(kali㉿KaliOnHP)-[~/coreutils]
└─$ /usr/bin/numfmt --from=iec 915339622.7555392131
915339622.7555392131

The f64 is not as precise as long double.
Even to igore the case, GNU numfmt still has an error when number is out of limitation(which WE don't):

┌──(kali㉿KaliOnHP)-[~/coreutils]
└─$ ./target/debug/numfmt --from=iec 915339622.7555392723748798127937497128934
915339622.7555392980575561523437500000000

┌──(kali㉿KaliOnHP)-[~/coreutils]
└─$ /usr/bin/numfmt --from=iec 915339622.7555392723748798127937497128934
numfmt: 值或精度过大,无法输出:"9.1534e+08/31"(请考虑使用 --to)

If anyone see this, pls NEW an ISSUE if it is reasonable, I'm worrying that this PR won't be merged, thus my environment is not relyable for now.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cp/link-heap is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!

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.

numfmt: large integers lose precision (f64 rounding) vs GNU

1 participant