0

I add this floating numbers in javascript,
1403.07+1000.00 result is 2403.0699999999997

It should be 2403.07

I got a work around (1403.07+1000.00).toFixed(2), but this will fail if precision changes meaning; it will fail for addition of 1403.072+1000.01.

Is there any way I can achieve by jQuery/Javascipt, i dont need external library.

  • This might be a better duplicate: [How to deal with floating point number precision in JavaScript?](http://stackoverflow.com/q/1458633/218196) ... anyways, if you search, you will find lots of questions about it. – Felix Kling Dec 05 '16 at 05:14

1 Answers1

0
var result = 2403.0699999999997;
result =   result.toFixed(2); //returns string fixed to 2 decimal places
result =   parseFloat(result);//returns double 2 decimal places
alert(result);

check this fiddle http://jsfiddle.net/azT97/62/

Raki
  • 535
  • 4
  • 13