May 21, 2009

A simple rounding script

return round(argument0*power(10,argument1))/power(10,argument1)

Simply put, this code will allow you to round to however many decimal places you want. If this code were a script named 'rnd', for example:

rnd(10.15332,0)=10
rnd(10.15332,1)=10.2
rnd(10.15332,2)=10.15

And so on. Please make note of that decimal in the second argument make this script blow up in your face, and negative values will indeed round to numbers higher than the decimal point.
(rnd(13.539,-1)=10, for example)