You should round after multiplying:
var d = (Math.round(1000*a)-Math.round(1000*b))/1000;
Just multiplying may not solve the problem. When you assign
var a = 16924.83;
it might internally represent this as something like 16924.8300001
, so when you multiply by 1000
you get 16924830.001
. You need to round to get rid of that fraction.