Math.min( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Math.min( ) Method Flash 5; can be used when exporting Flash 4 movies

determine the smaller of two numbers
Math.min(x, y)

Arguments

x

A number.

y

A number.

Returns

The smaller of x and y.

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( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net