Fixes occasional rounding error in Javascript using simple methods.