Skip to content

Conversation

@naoNao89
Copy link
Contributor

Big numbers like i64::MAX were showing up wrong in error messages because fluent-rs converts everything to f64 internally. This breaks numbers beyond ±2^53.

Quick fix: check the range first. If it's too big for f64 to handle safely, we pass it as a string instead. Now 9223372036854775807 shows correctly instead of 9223372036854776000.

This is a temporary workaround until fluent-rs fixes their precision issue upstream.

Closes #9294

Related: projectfluent/fluent-rs#337

@mfontanaar
Copy link

mfontanaar commented Nov 16, 2025

I think the approach is still bugged, because you are leaving out the case of having a u64 greater than i64::MAX.

I had created a (rough) PR which I think functionally is more correct, but whose code is very ugly (yours is much more polished). You can see the relevant commit here: temp-mfontanaar@4bb0e01

That being said, I'm puzzled about how does your approach works. In my tests, it seemed like FluentArgs was always converting to a f64 , regardless of whether the input was str or i64. But your passing tests are proving me wrong.

@naoNao89
Copy link
Contributor Author

hmm

@sylvestre
Copy link
Contributor

not super happy that it will be added this in every call of translate!()

@naoNao89
Copy link
Contributor Author

Extracted logic to safe_set_fluent_arg() helper

@naoNao89 naoNao89 force-pushed the fix-9294-big-number-precision branch from 306880a to a484d4d Compare November 16, 2025 20:58
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 16, 2025

CodSpeed Performance Report

Merging #9300 will improve performances by 8.22%

Comparing naoNao89:fix-9294-big-number-precision (52f4c2a) with main (29ec8f3)

Summary

⚡ 2 improvements
✅ 121 untouched
⏩ 6 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
fold_custom_width[50000] 32.1 ms 30 ms +6.96%
fold_many_lines[100000] 77.8 ms 71.9 ms +8.22%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 force-pushed the fix-9294-big-number-precision branch 2 times, most recently from fc18e0d to 9828d57 Compare November 16, 2025 21:53
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

i think it has a bit too much complexity for a corner case :/

The translate! macro lost precision for u64 > i64::MAX due to
f64 fallback. Now parses u64 before f64 to maintain accuracy.

Fixes uutils#9294
@naoNao89 naoNao89 force-pushed the fix-9294-big-number-precision branch from 9828d57 to 52f4c2a Compare November 17, 2025 12:35
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

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.

[LOCALIZATION] Handling of big numbers

3 participants