Possible en double:
Is JavaScript's Math broken?Javascript ajout flotteur
<html>
<body>
<script type="text/javascript">
var w = 0;
var weight1 = parseFloat("0.6");
var weight2 = parseFloat("0.3");
w = weight1 + weight2;
document.write("total weight: " + w);
</script>
</body>
</html>
Pourquoi cette impression ,8999999999999999 et non 0,90000000
Bienvenue aux nombres à virgule flottante! –
Duplicata de http://stackoverflow.com/questions/1088216/whats-wrong-with-using-to-compare-floats-in-java? – PleaseStand
Voir: http://stackoverflow.com/questions/1036662/weird-javascript-behaviour-floating-point-addition-giving-the-wrong-answer –