eva
eva copied to clipboard
Precision problem with floating points numbers
Hi!
Less words, more example. When I'm trying to add up 41.90 + 91.90 + 209 + 249
eva gave a 591.7999999999
, although I expected 591.80
.
noted. eva
uses rust's floating point arithmetic, we should definitely move over to fixed point arithmetic.
I'm not a big expert in computer arithmetic, but my research (a.k.a browsing Wikipedia) suggest to look at "Arbitrary-precision arithmetic" since bc
use similar approach.
rug seems like a nice choice. It's implement Integer
, Rational
and Float
and configurable (you can turn off Complex
numbers). The only drawback I found was the dependence on GNU libraries.
I recently just noticed this issue, isn't num solving this? I think it's num_rational
that provides arbitrary precision.
@pickfire I am afraid I never got around to actually implementing it (I imported the num
crate and completely forgot about it soon after)
@NerdyPepper Heh, you could make this a hacktoberfest issue and hope someone solve it.
In Excel, i have these 591.800000000000068. Relative failure of 1.15E-16. Welcome in the real world ;-)
Running cargo r
on the master branch works fine for me:
The display is fixed in master branch, but still it doesn't support numbers larger than f64, I guess this can be closed for now.