
Math.random() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
611
Description
The pow( ) method can be used to raise any number to any power. If exponent is negative,
pow( ) returns 1 / (
base
abs(exponent)
). If exponent is a fraction, pow( ) can be used to take the
square root or cube root, and so on, of a number (in which case it returns the positive root,
although, mathematically, there may also be a negative root).
Example
Math.pow(5, 2); // Returns 25 (5 squared)
Math.pow(5, 3); // Returns 125 (5 cubed)
Math.pow(5, -2); // Returns 0.04 (1 divided by 25)
Math.pow(8, 1/3); // Returns 2 (cube root of 8)
Math.pow(9, 1/2); // Returns 3 (square root of 9)
Math.pow(10, 6); // Returns 1000000 (can also be written as 1e6)
Bugs
Flash Player 5.0.30.0 did not correctly calculate Math.pow( ) for negative values of base. For
example, Math.pow(–2, 2) was calculated as
NaN, whereas it should be 4. This was fixed in
Flash Player 6.
See Also
Math.exp( ), Math.sqrt( ), Math.SQRT2, Math.SQRT1_2
Math.random() Method
generate a random number from 0 to 1.0
Flash 5; can be used when exporting Flash 4 movies
Math.random()
Returns
A floating-point number greater than or equal to 0.0 and less than 1.0.
Description
The random( ) method provides a way to produce random numbers, which can then be
used to choose randomly between actions ...