Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Math > round (Math.round method) | |||
public static round(x:Number) : Number
Rounds the value of the parameter x up or down to the nearest integer and returns the value. If parameter x is equidistant from its two nearest integers (that is, the number ends in .5), the value is rounded up to the next higher integer.
Availability: ActionScript 1.0; 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.
x:Number - A number.
Number - A number; an integer.
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+1) + (min-.5));
return randomNum;
}
for (var i = 0; i<25; i++) {
trace(randRange(4, 11));
}
ceil (Math.ceil method), floor (Math.floor method)
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001837.html
Comments
No screen name said on Aug 15, 2007 at 7:01 AM :