2 ms·
In guile[1]: % guile guile> (= (+ 0.1 0.2) 0.3) #f [1] - https://www.gnu.org/software/guile/ https://www.gnu.org/software/guile/
by pmoriarty 12y ago
In guile[1]:
% guile
guile> (= (+ 0.1 0.2) 0.3)
#f
[1] - https://www.gnu.org/software/guile/ https://www.gnu.org/software/guile/
- jgrant27 12y agoGuile(and most Lisps such as Common Lisp) support rationals specifically to avoid this problem, why not just use them ? scheme@(guile-user)> (= (+ 1/10 2/10) 3/10) $1 = #t
- draegtun 12y agoperl6 also use rationals (by default)... $ perl6 > 0.1 + 0.2 == 0.3 True > (0.1 + 0.2).perl 3/10 For perl5 you must use the bigrat pragma: $ re.pl > 0.1 + 0.2 != 0.3 1 > use bigrat; > 0.1 + 0.2 == 0.3 1 ref: http://perldoc.perl.org/bigrat.html http://perldoc.perl.org/bigrat.html
- pmoriarty 12y ago"why not just use them ?" Sometimes decimal notation is the most natural, and sometimes you're copying numbers in decimal notation out of a book, wikipedia, or some other publication.