Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
A data type representing an IEEE-754 single-precision floating-point number. You can manipulate primitive numeric
values by using the methods and properties associated with the float class, as well as normal arithmetic operators.
Float values are stored as 32-bit values and are supported in ActionScript Byte Code version 47.16 and above.
To use single-precision floating point functionality, you will need to compile your application using the AIR compiler
version 3.0.0 or above (provided with AIR SDK 51.0), and the target AIR runtime would need to be AIR 51.0 or above.
The properties of the float class are static, which means you do not need an object to use them, so you
do not need to use the constructor.
The float data type adheres to the single-precision IEEE-754 standard.
The float data type is useful when you need to use floating-point values without needing the precision or using the
memory associated with the double-precision Number
type. This can be particularly useful when interacting
with graphical systems such as the Stage3D APIs, where float
-specific functions are now available for program
constants and vertex buffers.
The default value of a variable typed as flat is NaN
(Not a Number). To assign number values to a float
variable, an 'f' character should be appended to the value - for example:
var floatVal:float = 1.23f;
Note that when a float
value is converted into a String
, the internal functionality will
promote the single-precision value into a double-precision value which will then be converted into a string. Some precision
changes may occur during this promotion/conversion process.
public function float(num:Object)
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Creates a float object with the specified value. This constructor has the same effect
as the float()
public native function that converts an object of a different type
to a primitive numeric value.
Parameters
AS3 function toExponential(fractionDigits:uint):String
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Returns a string representation of the float value in exponential notation. The string contains
one digit before the decimal point and up to 20 digits after the decimal point, as
specified by the fractionDigits
parameter.
Parameters
| fractionDigits:uint — An integer between 0 and 20, inclusive, that represents the desired number of decimal places.
|
Returns
Throws
| RangeError — Throws an exception if the fractionDigits argument is outside the range 0 to 20.
|
AS3 function toFixed(fractionDigits:uint):String
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Returns a string representation of the float value in fixed-point notation.
Fixed-point notation means that the string will contain a specific number of digits
after the decimal point, as specified in the fractionDigits
parameter.
The valid range for the fractionDigits
parameter is from 0 to 20.
Specifying a value outside this range throws an exception.
Parameters
| fractionDigits:uint — An integer between 0 and 20, inclusive, that represents the desired number of decimal places.
|
Returns
Throws
| RangeError — Throws an exception if the fractionDigits argument is outside the range 0 to 20.
|
AS3 function toPrecision(precision:uint):String
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Returns a string representation of the float value either in exponential notation or in
fixed-point notation. The string will contain the number of digits specified in the
precision
parameter.
Parameters
| precision:uint — An integer between 1 and 21, inclusive, that represents the desired number of digits to represent in the resulting string.
|
Returns
Throws
| RangeError — Throws an exception if the precision argument is outside the range 1 to 21.
|
AS3 function toString(radix:* = 10):String
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Returns the string representation of the specified float object.
If the value of the float object is a decimal number without a leading zero (such as .4
),
float.toString()
adds a leading zero (0.4
).
Note that the conversion internally promotes the single-precision value into a double-precision
value which is then converted to a string, hence the resulting precision may be higher than expected.
Parameters
| radix:* (default = 10 ) — Specifies the numeric base (from 2 to 36) to use for the number-to-string
conversion. If you do not specify the radix parameter, the default value
is 10.
|
Returns
| String —
The numeric representation of the float object as a string.
|
AS3 function valueOf():float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Returns the primitive value type of the specified float object.
Returns
| float —
The primitive type value of the float object.
|
public static const MAX_VALUE:float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
The largest representable number (single-precision IEEE-754). This number is
approximately 3.4e38.
public static const MIN_VALUE:float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
The smallest (closest to zero, not most negative) representable single-precision IEEE-754 number that does not compare equal to zero.
On most platforms this number is approximately 1.4e-45.
Note: The absolute smallest representable number overall is -float.MAX_VALUE
.
public static const NaN:float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
The single-precision IEEE-754 value representing Not a Number (NaN
).
public static const NEGATIVE_INFINITY:float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Specifies the single-precision IEEE-754 value representing negative infinity.
Negative infinity is a special numeric value that is returned when a mathematical
operation or function returns a negative value larger than can be
represented.
public static const POSITIVE_INFINITY:float
Language version: | ActionScript 3.0
|
Runtime version: | AIR 51.0
|
Specifies the single-prevision IEEE-754 value representing positive infinity.
Positive infinity is a special numeric value that is returned when a mathematical
operation or function returns a value larger than can be represented.
© 2004-2022 Adobe Systems Incorporated. All rights reserved.
Mon Feb 12 2024, 3:03 PM GMT