Re:0.30000000000000004
by Tepix on Friday November 13, 2015 @05:56AM
(#10559126)
Yep, it's better to print the result of 0.1+0.2-0.3
[ Parent
| on HN ]
Not generally!
$ perl -E 'say sprintf "%.64f", 0.1 + 0.2'
0.3000000000000000000108420217248550443400745280086994171142578125
$ perl -E 'say sprintf "%.64f", 0.1 + 0.2 - 0.3'
0.0000000000000000000000000000000000000000000000000000000000000000
My Perl is configured with -Dusemorebits. https://metacpan.org/pod/distribution/perl/INSTALL#more-bits