1

I calculate a lot of number with javascript. In some calculation i have a bad result.

Exemple: http://jsfiddle.net/6et8d10c/

var num1 = 2.01;
var num2 = 22.29;
var result = num1 + num2; //24.29 (should be 24.30)

For now I fix with: (2.01*100 + 22.29*100) / 100 = 24.30

That's not perfect. Why can't i calculate 2.01 + 22.29 ?

Sancho
  • 1,288
  • 2
  • 25
  • 50

0 Answers0