Number

Lets you work with numeric values. The Number object is an object wrapper for primitive numeric values and a core object.

Created by

The Number constructor.

Syntax

new Number(value);

Parameters

value

The numeric value of the object being created.

Description

The primary uses for the Number object are:

The properties of Number are properties of the class itself, not of individual Number objects.

Number(x) now produces NaN rather than an error if x is a string that does not contain a well-formed numeric literal. For example:

x=Number("three");
Console.Write(x);
prints NaN

Examples

The following example uses the Number object's properties to assign values to several numeric variables:

biggestNum = Number.MAX_VALUE
smallestNum = Number.MIN_VALUE
infiniteNum = Number.POSITIVE_INFINITY
negInfiniteNum = Number.NEGATIVE_INFINITY
notANum = Number.NaN

The following example creates a Number object, myNum, then adds a description property to all Number objects. Then a value is assigned to the myNum object's description property.

myNum = new Number(65)
Number.prototype.description=null
myNum.description="wind speed"