
parseInt() Global Function
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
736
|
ActionScript Language Reference
Description
The parseFloat() function converts a string to a floating-point number (a number with a
fractional portion). It returns a useful value only for strings that contain a valid string repre-
sentation of a floating-point number; otherwise,
NaN is returned. The string must be of the
following form:
• A valid starting character. Valid characters are +, –, 0 through 9, e, E, and ., although
optional leading whitespace is acceptable (and ignored).
• Optional sign indicator (+ or –).
• At least one digit from 0–9 and an optional decimal point.
• Optional exponent starting with
e or E followed by integer exponent, which can itself
include an optional sign indicator (+ or –)—for example, “10e–3”.
Trailing characters that cannot be parsed as part of the preceding numeric format are
ignored but do not necessarily cause
NaN to be returned. The number derived from the
supplied string starts with the first nonblank character in the string and ends with the char-
acter before the first character that is not a legitimate character.
Usage
Because user-input data entered into text fields always belongs to the string datatype, we
often use parseFloat() to extract numeric data from user-supplied text. Note that
parseFloat() can extract