Rounding

is there an easy way to specify how many digits after the decimal flash will return in a variable. I know you can do it in a sort of complicated way like this:
[AS]
//say i want 3 decimal places out of number
number = 100.12345
number *= 1000;
Math.round(number);
number /= 1000;
[/AS]

but is there a better way, something like
Math.roundPlaces(number, 3);
?
thanks

not that i know of :frowning:
but this is shorter :wink:


number = Math.round(number*1000)/1000;

:}

:slight_smile: thanks master 64 but I was just wondering if there was a better way. sadly, i guess not.


function roundDecs(number, decs){
var timesBy = Math.pow(10, decs);
return Math.round(number*timesBy)/timesBy
}

:wink:

ooh nice. make it into a nifty little function. :wink: ok that should work for what I need. Thanks a bunch guys.