The Javascript Number class has a toFixed()
function that will get you what you want.
So you could do parseFloat("1.0019999").toFixed(3)
and that would give you 1.002.
The parameter (3 in this case) is the number of digits to show after the decimal point