Due to the floating point standard that Javascript implements, doing arithmetic with decimal values is buggy to say the least...
One work around is to convert the decimals to integers by multiplying by 100, doing the math then dividing by 100.
This only works well if you have at most 2 decimals places. If you require more precision than that, I would recommend a language other than Javascript for that part.