Closed jhoobergs closed 2 months ago
Hi! Thanks for reporting!
I'm open to PRs to fix it, and ultimately, we hope to move our numbers formatting to use ICU4X once it gains NumberFormat API.
I renamed the issue, because the problem is bigger. It can also go wrong for whole numbers, because f64 can't represent all whole numbers.
e.g. 18014398509481985
is printed as 18014398509481984
(one lower).
(explanation at https://stackoverflow.com/a/19474852)
This issue is a duplicate of #337. That issue is of course later than this one, but since it has some suggestions of a fix I think I'll close this version no discussion continues elsewhere. There is also icu4x stuff in progress (see #269 and #329) that relates to this. I would suggest subscribing to #337 if you want to be notified when this is fixed.
When using variables representing floating numbers, strange situations can arise. The reason for this is https://docs.rs/fluent-bundle/0.14.0/src/fluent_bundle/types/number.rs.html#178 where everything is converted to a
f64
.e.g if you use
let v : f32 = 300072.3;
and passv
as a FluentValue, it will be shown as300072.3125
because off64
's higher accuracy.If you would keep it as a f32, however, it would be shown correctly?