function roundToDecimal(val:Number, places:int):Number {
var factor:int = Math.pow(10, places)
return Math.round(val * factor) / factor;
}
trace(roundToDecimal(Math.random(), 1));
trace(roundToDecimal(Math.random(), 2));
trace(roundToDecimal(Math.random(), 3));
__
and this
Math.round(number * 100) / 100;
?
[]'s
andrei
On 9/14/07, Paul Steven <[EMAIL PROTECTED]> wrote:
>
> I would be interested to know how people format numbers in AS3 to 2
> decimal
> places.
>
> I am currently using the following but it does not always appear to work:
>
> var displayP
I would be interested to know how people format numbers in AS3 to 2 decimal
places.
I am currently using the following but it does not always appear to work:
var displayPercentageValue:Number = Math.round(percentageValue / .01) * .01;
Sometimes it seems to be displaying correctly, sometimes it d
3 matches
Mail list logo