Math.round() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

Math.round()

Availability
Flash Player 5. In Flash Player 4, the methods and properties of the Math class are emulated using
approximations and might not be as accurate as the non-emulated math functions that Flash
Player 5 supports.
Usage
Math.round(x:Number) : Number
Parameters
A number.
x
Returns
A number; an integer.
Description
Method; rounds the value of the parameter
the value. If parameter
.5), the value is rounded up to the next higher integer.
Example
The following example returns a random number between two specified integers.
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min))+min;
return randomNum;
}
for (var i = 0; i<25; i++) {
trace(randRange(4, 11));
}
See Also
Math.ceil(),
is equidistant from its two nearest integers (that is, the number ends in
x
Math.floor()
up or down to the nearest integer and returns
x
Math.round()
441

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents