
Math.PI Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
610
|
ActionScript Language Reference
Description
The min( ) function compares two numbers and returns the smaller of the two. When
comparing two negative numbers, the one with a larger absolute value is actually smaller
(see the following Example). If used on strings, min( ) returns
NaN.
Example
Math.min(5, 1); // Returns 1
Math.min(-6, -5); // Returns -6
Math.min(Math.abs(-6), Math.abs(-5)); // Returns 5
Reader Exercise: Modify the example under Math.max( ) to return the minimum value in
an array rather than the maximum.
See Also
Math.abs( ), Math.max( )
Math.PI Property
the ratio of a circle’s circumference to its diameter, approximately 3.14159
Flash 5; can be used when exporting Flash 4 movies
Math.PI
Description
The PI property represents the constant π, the ratio of the circumference of a circle to its
diameter.
Example
Math.PI is famously used in calculating the area of a circle:
function circleArea (radius) {
// PI times the radius squared can also be written
// as Math.PI * Math.pow(radius, 2)
return Math.PI * (radius * radius);
}
See Also
Math.cos( ), Math.sin( )
Math.pow() Method
raise a number to a specified power
Flash 5; can be used when exporting Flash 4 movies
Math.pow(base, exponent)
Arguments
base A number representing the base of the exponential expression.
exponent ...