I have noticed that all rounding to x decimals scripts uses the following format:
tenToPower = Math.pow(10, nDecimals);newNumber = String((Math.round(nNumber * tenToPower) / tenToPower));
However, that doesn’t work with numbers like 0.5005, yet DOES work with 0.50051. Any idea why, and how to fix the script above?
You can try this out by entering the following into the location/address bar of your browser:
Unfortunately, there’s no simple workaround for this problem. You might try multiplying by another power of ten and then dividing by that on the other side.