Name
Math.sqrt( ) Method — calculate the square root of a number
Availability
Flash 5; may be used when exporting Flash 4 movies
Synopsis
Math.sqrt(x)
Arguments
- x
A non-negative integer.
Returns
The square root of x
, or
NaN
if x
is less than
0.
Description
The sqrt( )
method returns the positive root of
its operand (even though there may also be a mathematically valid
negative root). It is equivalent to:
Math.pow(x, 0.5)
Example
Math.sqrt(4); // Returns 2, although -2 is also a valid root Math.sqrt(36); // Returns 6, although -6 is also a valid root Math.sqrt(-20); // Returns NaN
See Also
Math.pow( )
, Math.SQRT2
,
Math.SQRT1_2
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.