de Doublons possibles:
Why 81.66 * 15 = 1224.8999999 in Javascript (or Perl) and not 1224.9 ?
Is JavaScript’s math broken?se multiplient en javascript ne peut pas obtenir la réponse correcte
var t1 = 5000;
var t2 = 0.07;
alert(t1 * t2);
est ici un code très simple qui renvoie un résultat incorrect; Je prédis le résultat est 350
mais le résultat est 350.00000000000005
Comment puis-je obtenir le résultat correct?
et quel est le problème dans ce code?
Ceci est une copie de l'une des façons suivantes: http : //stackoverflow.com/questions/2387675/why-81-66-15-1224-8999999-in-javascript-or-perl-and-not-1224-9 http://stackoverflow.com/questions/228 4873/float-inexactitudes-in-python http://stackoverflow.com/questions/2379934/unexpected-result-using-posix-ceil-in-perl http://stackoverflow.com/questions/872544/precision-of- flottant –
En effet ... Un classique bien usé: http://stackoverflow.com/questions/588004/is-javascripts-math-broken – Shog9
[Lire] (http://en.wikipedia.org/wiki/ Point flottant). C'est un doublon d'un million d'autres questions. –