we often have to round numbers in our scripts (or expressions). I usually use the Math.round() method to accomplish this, for example:
Code: Select all
x = 57.351245;
alert(Math.round(x*100)/100); // 2-digit precision -> 57.35
Example:
Code: Select all
pi = 3.14159;
alert(pi.toFixed(2)); // 2-digit precision -> 3.14
I guess some of you already know this method but I don't remember to have seen it already in a script so ...