in reply to Re: floating point addition
in thread floating point addition
To eliminate the problem you could use bigrat and use fractions.
Compare:
perl -Mbignum -e ' printf "%20.17f\n", 20.1;' 20.10000000000000142 perl -Mbigrat -e ' printf "%20.17f\n", 20.1;' 20.10000000000000142 perl -Mbigrat -e ' printf "%20.17f\n", 20+1/10; 20.00000000000000000
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: floating point addition
by choroba (Cardinal) on Jan 12, 2015 at 18:09 UTC | |
by morgon (Priest) on Jan 12, 2015 at 20:15 UTC | |
by choroba (Cardinal) on Jan 12, 2015 at 22:49 UTC | |
by morgon (Priest) on Jan 13, 2015 at 01:34 UTC | |
by choroba (Cardinal) on Jan 13, 2015 at 08:39 UTC |