Name

Number Class — wrapper class for primitive numeric data

Availability

Flash 5

Constructor

new Number(value)

Arguments

value

An expression to be resolved and, if necessary, converted to a numeric value, then wrapped in a Number object.

Class Properties

The following properties are accessed directly as properties of the Number class, using Number . propertyName. To access them you do not need to instantiate a new Number object (i.e., there is no need for the constructor function). Some of these properties, such as NaN don’t even require the Number . propertyName notation. You can simply use NaN as shorthand for Number . NaN (details for each property follow later).

MAX_VALUE

The largest representable positive number in ActionScript.

MIN_VALUE

The smallest representable positive number in ActionScript.

NaN

Special Not-a-Number value indicating invalid numeric data.

NEGATIVE_INFINITY

Any number more negative than -MAX_VALUE.

POSITIVE_INFINITY

Any number larger than MAX_VALUE.

Methods

toString( )

Convert a number to a string.

Description

The Number class has two purposes:

  • It gives us access to built-in properties that represent special numeric values—MIN_VALUE, MIN_VALUE, NaN, NEGATIVE_INFINITY, and POSITIVE_INFINITY—that can be used to check whether numeric data is valid.

  • It can be used to convert between different number systems, such as base-10 (decimal) and base-16 (hexadecimal). Refer to Number.toString( ) method.

Usage

There is no need to create a new Number object if you simply want to access the ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.