Number


Number is the built-in object corresponding to the primitive number data type. As discussed in Chapter 3, all numbers are represented in IEEE 754-1985 double-precision floating-point format. This representation is 64 bits long, permitting floating-point magnitudes as large as ±1.7976 10 308 and as small as ±2.2250 10 -308 . The Number() constructor takes an optional argument specifying its initial value:

 var x = new Number(); var y = new Number(17.5); 

Table 7-5 lists the special numeric values that are provided as properties of the Number object.

Table 7-5: Properties of the Number Object

Property

Value

Number.MAX_VALUE

Largest magnitude representable

Number.MIN_VALUE

Smallest magnitude representable

Number.POSITIVE_INFINITY

The special value Infinity

Number.NEGATIVE_INFINITY

The special value -Infinity

Number.NaN

The special value NaN

The only useful method of this object is toString() , which returns the value of the number in a string. Of course it is rarely needed, given that generally a number type converts to a string when we need to use it as such.




JavaScript 2.0
JavaScript: The Complete Reference, Second Edition
ISBN: 0072253576
EAN: 2147483647
Year: 2004
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net