1

Working on a form where I am doing a minus from two forms and showing the result in the third one. The problem is when I am for example doing: 0,79 - 0,43 the result becomes: 0,36000000000000004.

So wondering if it's possible to round it to two decimals ?

Jsfiddle: http://jsfiddle.net/eYj8B/12/

enter image description here

user3185936
  • 1,567
  • 6
  • 23
  • 44
  • THIS WILL HELP http://stackoverflow.com/questions/8503157/ieee-754-floating-point-arithmetic-rounding-error-in-c-sharp-and-javascript – Jitesh Mar 30 '14 at 17:42

2 Answers2

5

toFixed does that

output.val(value.toFixed(2).replace('.', ','));

FIDDLE

adeneo
  • 312,895
  • 29
  • 395
  • 388
0

Try this:

Use Math.round(num * 100) / 100
pj013
  • 1,393
  • 1
  • 10
  • 28