Erreurs décimales : Différence entre versions

De Asso Val Libre
Aller à : navigation, rechercher
(0.1+0.2 = ???)
 
(4 révisions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
== Grand classique ==
+
= 0.1+0.2 = ??? =
  
 
* https://docs.python.org/fr/2.7/tutorial/floatingpoint.html
 
* https://docs.python.org/fr/2.7/tutorial/floatingpoint.html
Ligne 16 : Ligne 16 :
 
   % puts [expr 0.1+0.2-0.3]
 
   % puts [expr 0.1+0.2-0.3]
 
   5.551115123125783e-17
 
   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 ==
 
== OK ==

Version actuelle en date du 4 novembre 2019 à 17:46

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)