Fix: Large numbers lose precision in localized messages#9300
Fix: Large numbers lose precision in localized messages#9300naoNao89 wants to merge 2 commits intouutils:mainfrom
Conversation
|
I think the approach is still bugged, because you are leaving out the case of having a 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 |
|
hmm |
|
not super happy that it will be added this in every call of translate!() |
|
Extracted logic to |
306880a to
a484d4d
Compare
CodSpeed Performance ReportMerging this PR will degrade performance by 9.77%Comparing Summary
Performance Changes
Footnotes
|
|
GNU testsuite comparison: |
fc18e0d to
9828d57
Compare
|
GNU testsuite comparison: |
|
i think it has a bit too much complexity for a corner case :/ |
9828d57 to
52f4c2a
Compare
|
GNU testsuite comparison: |
|
Where are we standing with this MR? I think it is important to try to provide some kind of workaround to the fluent limitation. |
|
Some improvements before it can be merged:
|
|
GNU testsuite comparison: |
854bf6c to
8d7b5d8
Compare
|
GNU testsuite comparison: |
8d7b5d8 to
9d3f17d
Compare
The translate! macro lost precision for u64 > i64::MAX due to f64 fallback. Now parses u64 before f64 to maintain accuracy. Fixes uutils#9294
Address maintainer feedback by refactoring the SafeFluentValue implementation: - Fix i64::MIN handling: Use range checks instead of unsigned_abs() - Eliminate string parsing: Use trait dispatch for type handling - Fix u64 overflow: Safe comparison without casting to i64 - Minimize allocations: Only convert to string when outside ±2^53 range The implementation correctly preserves precision for large integers while maintaining performance for typical values.
9d3f17d to
828d18c
Compare
|
GNU testsuite comparison: |
|
please reopen when ready (or ping me) |
Big numbers like
i64::MAXwere 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
9223372036854775807shows correctly instead of9223372036854776000.This is a temporary workaround until fluent-rs fixes their precision issue upstream.
Closes #9294
Related: projectfluent/fluent-rs#337