
isFinite() Global Function
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
554
|
ActionScript Language Reference
Example
int(4.5) // Yields 4
int(-4.5) // Yields -4
int(3.999) // Yields 3
The int( ) function is useful to check if a number is a whole number, by comparing the orig-
inal number to the result of the int( ) function:
if (int(x) != x) {
trace("Please enter a whole number for your age in years");
}
See Also
Math.ceil( ), Math.floor( ), Math.round( ), Number( ), parseFloat( ), parseInt( )
isFinite() Global Function
check if a number is less than Infinity and greater than –Infinity
Flash 5
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.Ifnumber 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."); ...