Took me forever to get this right. In Javascript, it can’t get the floating point right at times, making currency calculation off by just a cent.

The solution for the above is to remove the decimal by multiplying by 100. Then add them up. And the error may still return after adding, so you .round() it. Then divide it back by 100 to get the decimal back.

a = 0.1
b = 0.1

a *= 100
b *= 100

c = a + b

c = Math.round(c)

c /= 100