-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Loss of precision with the f64
conversion
#267
Comments
Hmm I think the loss of precision happens at this step: Lines 2663 to 2664 in 916bf3d
This division converts to two Do we know what algorithm rust's stdlib uses for parsing |
That particular calculation actually looks like it's correct in my models here. The calculation causing the issue is this: (integral_part as f64) + frac_f64 In fact, the result can be replicated by: let i = 1_u128;
let j = 0.59283191_f64;
println!("{}", (i as f64) + j); That being said, as you mention - we could potentially leave the conversion to |
In fact, this is not even a result of the let i = 1_f64;
let j = 0.59283191_f64;
println!("{}", i + j); outputs |
Hi. I've been investigating a bug today about a loss of precision, and I pointed it now to the mantissa algorithm in
Decimal
'sto_f64
. This is the code that fails in our system, and I'd like to know is the loss of precision expected or can it be a bug?What I can do in our case is to just go from string to float, keeping the precision and our users happy. This will not be as performant though, so I'm interested is the mantissa algorithm supposed to lose some precision, or could we maybe fix it?
rust_decimal version 1.7.0.
The PR: #235
Ping @paupino @hengchu
The text was updated successfully, but these errors were encountered: