isFinite( ) Global Function

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
isFinite( ) Global Function Flash 5

check if a number is less than Infinity and greater than -Infinity
isFinite(number)

Arguments

number

Any numeric value or expression that yields a numeric value.

Returns

The Boolean true if the number falls between -Number.MAX_VALUE and Number.MAX_VALUE (inclusive); otherwise, false. If number does not belong to the number datatype, number is converted to the number type before isFinite( ) executes.

Description

The isFinite( ) function simply checks if a number is in the legal numeric value range of ActionScript. It is equivalent to checking whether number is a number less than Infinity and greater than -Infinity. Use isFinite( ) before executing code that requires a legitimate number to operate properly.

Example

if (!isFinite(x * y)) {           // Test if the number is not finite   trace("The answer is too large to display. Try again."); } isFinite(-2342434);              // Yields true isFinite(Math.PI);               // Yields true isFinite(Infinity)               // Yields false isFinite(-Infinity)              // Yields false isFinite(NaN)                    // Yields false

See Also

-Infinity, Infinity, isNaN( ), Number.MAX_VALUE, Number.MIN_VALUE; Section 4.3.3



    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