‟Ex igne vita”

When

is called
as a function rather than as a constructor, it performs a type
conversion.**Number**

Returns
a Number value (not a Number object) computed by ToNumber(*value*)
if *value* was
supplied, else returns **+0**.

When

is called
as part of a **Number**

expression it is a constructor: it initialises the newly created
object.**new**

The
[[Prototype]] internal property of the newly constructed object is
set to the original Number prototype object, the one that is the
initial value of

(15.7.3.1).**Number.prototype**

The
[[Class]] internal property of the newly constructed object is set
to

.**"Number"**

The
[[PrimitiveValue]] internal property of the newly constructed object
is set to ToNumber(*value*)
if *value* was
supplied, else to +0.

The
[[Extensible]] internal property of the newly constructed object is
set to **true**.

The value of the [[Prototype]] internal property of the Number constructor is the Function prototype object (15.3.4).

Besides
the internal properties and the

property (whose value is **length****1**), the Number constructor has the
following property:

The
initial value of

is the Number prototype object (15.7.4).**Number.prototype**

This
property has the attributes { [[Writable]]: **false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The
value of

is the largest positive finite value of the Number type, which is
approximately 1.7976931348623157 × 10**Number.MAX_VALUE**^{308}.

This
property has the attributes { [[Writable]]: **false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The
value of

is the smallest positive value of the Number type, which is
approximately 5 × 10**Number.MIN_VALUE**^{ 324}.

This
property has the attributes { [[Writable]]: **false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The
value of

is **Number.NaN****NaN**.

**false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The value of Number.NEGATIVE_INFINITY is −∞.

**false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The value of Number.POSITIVE_INFINITY is +∞.

**false**,
[[Enumerable]]: **false**, [[Configurable]]: **false** }.

The
Number prototype object is itself a Number object (its [[Class]] is

)
whose value is +0.**"Number"**

The value of the [[Prototype]] internal property of the Number prototype object is the standard built-in Object prototype object (15.2.4).

Unless
explicitly stated otherwise, the methods of the Number prototype
object defined below are not generic and the this value passed to
them must be either a Number value or an Object for which the value
of the [[Class]] internal property is

.**"Number"**

In
the following descriptions of functions that are properties of the
Number prototype object, the phrase “this Number object” refers
to either the object that is the **this** value for the
invocation of the function or, if Type(**this** value) is Number,
an object that is created as if by the expression **new
Number(****this** value

where **)**

is
the standard built-in constructor with that name. Also, the phrase
“this Number value” refers to either the Number value
represented by this Number object, that is, the value of the
[[PrimitiveValue]] internal property of this Number object or the
**Number****this** value if its type is Number. A **TypeError**
exception is thrown if the **this** value is neither an object
for which the value of the [[Class]] internal property is

or a value whose type is Number.**"Number"**

The
initial value of

is the built-in **Number.prototype.constructor**

constructor.**Number**

The
optional *radix*
should be an integer value in the inclusive range 2
to 36. If *radix*
not present or is **undefined** the Number 10
is used as the value of *radix*.
If ToInteger(*radix*)
is the Number 10 then
this Number value is given as an argument to the ToString abstract
operation; the resulting String value is returned.

If
ToInteger(*radix*)
is not an integer between 2 and 36 inclusive throw a RangeError
exception. If ToInteger(*radix*)
is an integer from 2 to 36, but not 10, the result is a String
representation of this Number value using the specified radix.
Letters

-**a**

are used for digits with values 10 through 35. The precise algorithm
is implementation-dependent if the radix is not 10, however the
algorithm should be a generalization of that specified in 9.8.1.**z**

The

function
is not generic; it throws a **toString****TypeError** exception if its **this**
value is not a Number or a Number object. Therefore, it cannot be
transferred to other kinds of objects for use as a method.

Produces
a String value that represents this Number value formatted according
to the conventions of the host environment’s current locale. This
function is implementation-dependent, and it is permissible, but not
encouraged, for it to return the same thing as

.**toString**

**NOTE** The
first parameter to this function is likely to be used in a future
version of this standard; it is recommended that implementations do
not use this parameter position for anything else.

Returns this Number value.

The

function
is not generic; it throws a **valueOf****TypeError** exception if its **this**
value is not a Number or a Number object. Therefore, it cannot be
transferred to other kinds of objects for use as a method.

Return
a String containing this Number value represented in decimal
fixed-point notation with *fractionDigits*
digits after the decimal point. If *fractionDigits*
is **undefined**, 0 is assumed. Specifically, perform the
following steps:

Let

*f*be ToInteger(*fractionDigits*). (If*fractionDigits*is**undefined**, this step produces the value

).**0**If

*f*< 0 or*f*> 20, throw a**RangeError**exception.Let

*x*be this Number value.If

*x*is**NaN**, return the String

.**"NaN"**Let

*s*be the empty String.If

*x*< 0, thenLet s be "

".**-**Let x = –x.

If

*x*≥ 10^{21}, thenLet

*m*= ToString(*x*).

Else,

*x*< 10^{21}Let

*n*be an integer for which the exact mathematical value of*n*÷ 10^{f}–*x*is as close to zero as possible. If there are two such*n*, pick the larger*n*.If

*n*= 0, let*m*be the String

. Otherwise, let**"0"***m*be the String consisting of the digits of the decimal representation of*n*(in order, with no leading zeroes).If

*f*≠ 0, thenLet

*k*be the number of characters in*m*.If

*k*≤*f*, thenLet

*z*be the String consisting of*f*+1–*k*occurrences of the character ‘`0`

’.Let

*m*be the concatenation of Strings*z*and*m*.Let

*k*=*f*+ 1.

Let a be the first

*k*–*f*characters of*m*, and let*b*be the remaining*f*characters of*m*.Let

*m*be the concatenation of the three Strings*a*,

, and**"."***b*.

Return the concatenation of the Strings

*s*and*m*.

The

property of
the **length**

method
is **toFixed****1**.

If
the

method
is called with more than one argument, then the behaviour is
undefined (see clause 15).**toFixed**

An
implementation is permitted to extend the behaviour of

for values of **toFixed***fractionDigits*
less than 0 or greater than 20. In this case

would not necessarily throw **toFixed****RangeError** for such values.

**NOTE** The
output of

may be more precise than **toFixed**

for some values because toString only prints enough significant
digits to distinguish the number from adjacent number values. For
example,
**toString**

(

returns **1000000000000000128).toString()**

,**"1000000000000000100"**

while
(

returns **1000000000000000128).toFixed(0)****"**

.**1000000000000000128"**

Return
a String containing this Number value represented in decmal
exponential notation with one digit before the significand's decimal
point and *fractionDigits*
digits after the significand's decimal point. If *fractionDigits*
is **undefined**, include as many significand digits as necessary
to uniquely specify the Number (just like in ToString except that in
this case the Number is always output in exponential notation).
Specifically, perform the following steps:

Let

*x*be this Number value.Let

*f*be ToInteger(*fractionDigits*).If

*x*is**NaN**, return the String

.**"NaN"**Let

*s*be the empty String.If

*x**<*0, thenLet

*s*be

.**"-"**Let

*x*= –*x*.

If

*x*= +∞, thenReturn the concatenation of the Strings

*s*and

.**"Infinity"**

If

*fractionDigits*is not**undefined**and (*f*< 0 or*f*> 20), throw a**RangeError**exception.If

*x*= 0, thenLet

*f*= 0.Let

*m*be the String consisting of*f*+1 occurrences of the character ‘`0`

’.Let

*e*= 0.

Else,

*x*≠ 0If fractionDigits is not

**undefined**, thenLet

*e*and*n*be integers such that 10^{f}≤*n*< 10^{f}^{+1}and for which the exact mathematical value of*n*× 10^{e}^{–}^{f}–*x*is as close to zero as possible. If there are two such sets of*e*and*n*, pick the*e*and*n*for which*n*× 10^{e}^{–}^{f}is larger.

Else,

*fractionDigits*is**undefined**Let

*e*,*n*, and*f*be integers such that*f*≥ 0, 10^{f}≤*n*< 10^{f}^{+1}, the number value for n × 10^{e}^{–}^{f}is*x*, and*f*is as small as possible. Note that the decimal representation of*n*has*f*+1 digits,*n*is not divisible by 10, and the least significant digit of*n*is not necessarily uniquely determined by these criteria.

Let

*m*be the String consisting of the digits of the decimal representation of*n*(in order, with no leading zeroes).

If

*f*≠ 0, thenLet

*a*be the first character of*m*, and let*b*be the remaining*f*characters of*m*.Let

*m*be the concatenation of the three Strings*a*,

, and**"."***b*.

If

*e*= 0, thenLet

*c*=**"+".**Let

*d*=**"0".**

Else

If

*e*> 0, then let*c*=**"+".**Else,

*e*≤ 0Let

*c*=

.**"-"**Let

*e*= –*e*.

Let

*d*be the String consisting of the digits of the decimal representation of*e*(in order, with no leading zeroes).

Let

*m*be the concatenation of the four Strings*m*,

,**"e"***c*, and*d*.Return the concatenation of the Strings

*s*and*m*.

The

property of
the **length**

method is **toExponential****1**.

If
the

method is called with more than one argument, then the behaviour is
undefined (see clause 15).**toExponential**

An
implementation is permitted to extend the behaviour of

for values of **toExponential***fractionDigits*
less than 0 or greater than 20. In this case

would not necessarily throw **toExponential****RangeError** for such values.

**NOTE** For
implementations that provide more accurate conversions than required
by the rules above, it is recommended that the following alternative
version of step 9.b.i be used as a guideline:

Let

*e*,*n*, and*f*be integers such that*f*≥ 0, 10^{f}≤ n < 10^{f}^{+1}, the number value for n × 10^{e}^{–}^{f}is x, and*f*is as small as possible. If there are multiple possibilities for*n*, choose the value of*n*for which*n*× 10^{e}^{–}^{f}is closest in value to*x*. If there are two such possible values of*n*, choose the one that is even.

Return
a String containing this Number value represented either in decimal
exponential notation with one digit before the significand's decimal
point and *precision*–1
digits after the significand's decimal point or in decimal fixed
notation with *precision*
significant digits. If *precision*
is **undefined**, call ToString (9.8.1) instead. Specifically,
perform the following steps:

Let

*x*be this Number value.If

*precision*is**undefined**, return ToString(*x*).Let

*p*be ToInteger(*precision*).If

*x*is**NaN**, return the String

.**"NaN"**Let

*s*be the empty String.If

*x*< 0, thenLet

*s*be

.**"-"**Let

*x*= –*x*.

If

*x*= +∞, thenReturn the concatenation of the Strings

*s*and

.**"Infinity"**

If

*p*< 1 or*p*> 21, throw a**RangeError**exception.If

*x*= 0, thenLet

*m*be the String consisting of*p*occurrences of the character ‘`0`

’.Let

*e*= 0.

Else

*x*≠ 0,Let

*e*and*n*be integers such that 10^{p}^{–1}≤*n*< 10^{p}and for which the exact mathematical value of*n*× 10^{e}^{–}^{p}^{+1}–*x*is as close to zero as possible. If there are two such sets of*e*and*n*, pick the*e*and*n*for which*n*× 10^{e}^{–}^{p}^{+1}is larger.Let

*m*be the String consisting of the digits of the decimal representation of*n*(in order, with no leading zeroes).If

*e*< –6 or*e*≥*p*, thenLet

*a*be the first character of*m*, and let*b*be the remaining*p*–1 characters of*m*.Let

*m*be the concatenation of the three Strings*a*,

, and**"."***b*.If

*e*= 0, thenLet

*c*=

and**"+"***d*=

.**"0"**

Else

*e*≠ 0,If

*e*> 0, thenLet

*c*=

.**"+"**

Else

*e*< 0,Let

*c*=

.**"-"**Let

*e*= –*e*.

Let

*d*be the String consisting of the digits of the decimal representation of*e*(in order, with no leading zeroes).

Let

*m*be the concatenation of the five Strings*s*,*m*,

,**"e"***c*, and*d*.

If

*e*=*p*–1, then return the concatenation of the Strings*s*and*m*.If

*e*≥ 0, thenLet

*m*be the concatenation of the first*e*+1 characters of*m*, the character ‘`.`

’, and the remaining*p*– (*e*+1) characters of*m*.

Else

*e*< 0,Let

*m*be the concatenation of the String

, –(**"0."***e*+1) occurrences of the character ‘

’, and the String**0***m*.

Return the concatenation of the Strings

*s*and*m*.

The

property of
the **length**

method is **toPrecision****1**.

If
the

method is called with more than one argument, then the behaviour is
undefined (see clause 15).**toPrecision**

An
implementation is permitted to extend the behaviour of

for values of **toPrecision***precision*
less than 1 or greater than 21. In this case

would not necessarily throw **toPrecision****RangeError** for such values.

Number
instances inherit properties from the Number prototype object and
their [[Class]] internal property value is

.
Number instances also have a [[PrimitiveValue]] internal property.**"Number"**

The [[PrimitiveValue]] internal property is the Number value represented by this Number object.