-3

I'm trying to calculate this:

           €70.00

Total VAT  €12.6

Total      €82.59

As you might notice the 12.6 becomes 82.59 in the total! is there a known problem for this issue?

user692942
  • 16,398
  • 7
  • 76
  • 175

1 Answers1

0

Because of floating point limitations you should always use integers (i.e. count in pennies) when dealing with money. At the very end of your calculations you may may convert back to Euros by dividing by 100.

var total = (7000 + 1260) / 100
Ben
  • 1,113
  • 1
  • 7
  • 14