Erreurs décimales

De Asso Val Libre
Aller à : navigation, rechercher

0.1+0.2 = ???

Python 
 Python 2.7.16 (default, Oct  7 2019, 17:36:04) 
 >>> 0.1+0.2
 0.30000000000000004
 >>> 0.1+0.2-0.3
 5.551115123125783e-17
Tcl 
 % puts [expr 0.1+0.2]
 0.30000000000000004
 % puts [expr 0.1+0.2-0.3]
 5.551115123125783e-17
Perl 
 echo "print 0.1+0.2" | perl
 0.3
 echo "print 0.1+0.2-0.3" | perl
 5.55111512312578e-17
Lisp 
 > (+ .1 .2)
 0.30000000000000004
 > (-  (+ .1 .2) .3)
 5.551115123125783e-17


OK

Numworks 
(calculatrice graphique basée Python)