# 21.3 The Math Object

The Math object:

- is %Math%.
- is the initial value of the
"Math" property of theglobal object . - is an
ordinary object . - has a [[Prototype]] internal slot whose value is
%Object.prototype% . - is not a
function object . - does not have a [[Construct]] internal method; it cannot be used as a
constructor with the`new`

operator. - does not have a [[Call]] internal method; it cannot be invoked as a function.

In this specification, the phrase “the `x`” has a technical meaning defined in

# 21.3.1 Value Properties of the Math Object

# 21.3.1.1 Math.E

The `e`, the base of the natural logarithms, which is approximately 2.7182818284590452354.

This property has the attributes { [[Writable]]:

# 21.3.1.2 Math.LN10

The

This property has the attributes { [[Writable]]:

# 21.3.1.3 Math.LN2

The

This property has the attributes { [[Writable]]:

# 21.3.1.4 Math.LOG10E

The `e`, the base of the natural logarithms; this value is approximately 0.4342944819032518.

The value of `Math.LOG10E`

is approximately the reciprocal of the value of `Math.LN10`

.

# 21.3.1.5 Math.LOG2E

The `e`, the base of the natural logarithms; this value is approximately 1.4426950408889634.

The value of `Math.LOG2E`

is approximately the reciprocal of the value of `Math.LN2`

.

# 21.3.1.6 Math.PI

The

# 21.3.1.7 Math.SQRT1_2

The

The value of `Math.SQRT1_2`

is approximately the reciprocal of the value of `Math.SQRT2`

.

# 21.3.1.8 Math.SQRT2

The

# 21.3.1.9 Math [ @@toStringTag ]

The initial value of the

This property has the attributes { [[Writable]]:

# 21.3.2 Function Properties of the Math Object

The behaviour of the functions `acos`

, `acosh`

, `asin`

, `asinh`

, `atan`

, `atanh`

, `atan2`

, `cbrt`

, `cos`

, `cosh`

, `exp`

, `expm1`

, `hypot`

, `log`

,`log1p`

, `log2`

, `log10`

, `pow`

, `random`

, `sin`

, `sinh`

, `sqrt`

, `tan`

, and `tanh`

is not precisely specified here except to require specific results for certain argument values that represent boundary cases of interest. For other argument values, these functions are intended to compute approximations to the results of familiar mathematical functions, but some latitude is allowed in the choice of approximation algorithms. The general intent is that an implementer should be able to use the same mathematical library for ECMAScript on a given hardware platform that is available to C programmers on that platform.

Although the choice of algorithms is left to the implementation, it is recommended (but not specified by this standard) that implementations use the approximation algorithms for `fdlibm`

, the freely distributable mathematical library from Sun Microsystems (http://www.netlib.org/fdlibm).

# 21.3.2.1 Math.abs ( `x` )

Returns the absolute value of `x`; the result has the same magnitude as `x` but has positive sign.

When the `Math.abs`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN , returnNaN . - If
`n`is-0 _{𝔽}, return+0 _{𝔽}. - If
`n`is-∞ _{𝔽}, return+∞ _{𝔽}. - If
`n`<+0 _{𝔽}, return -`n`. - Return
`n`.

# 21.3.2.2 Math.acos ( `x` )

Returns the inverse cosine of `x`. The result is expressed in radians and ranges from _{𝔽} to

When the `Math.acos`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`>1 _{𝔽}, or`n`<-1 _{𝔽}, returnNaN . - If
`n`is1 _{𝔽}, return+0 _{𝔽}. - Return an
implementation-approximated value representing the result of the inverse cosine ofℝ (`n`).

# 21.3.2.3 Math.acosh ( `x` )

Returns the inverse hyperbolic cosine of `x`.

When the `Math.acosh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN or`n`is+∞ _{𝔽}, return`n`. - If
`n`is1 _{𝔽}, return+0 _{𝔽}. - If
`n`<1 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the inverse hyperbolic cosine ofℝ (`n`).

# 21.3.2.4 Math.asin ( `x` )

Returns the inverse sine of `x`. The result is expressed in radians and ranges from

When the `Math.asin`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`>1 _{𝔽}or`n`<-1 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the inverse sine ofℝ (`n`).

# 21.3.2.5 Math.asinh ( `x` )

Returns the inverse hyperbolic sine of `x`.

When the `Math.asinh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - Return an
implementation-approximated value representing the result of the inverse hyperbolic sine ofℝ (`n`).

# 21.3.2.6 Math.atan ( `x` )

Returns the inverse tangent of `x`. The result is expressed in radians and ranges from

When the `Math.atan`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`is+∞ _{𝔽}, return animplementation-approximated value representing π / 2. - If
`n`is-∞ _{𝔽}, return animplementation-approximated value representing -π / 2. - Return an
implementation-approximated value representing the result of the inverse tangent ofℝ (`n`).

# 21.3.2.7 Math.atanh ( `x` )

Returns the inverse hyperbolic tangent of `x`.

When the `Math.atanh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`>1 _{𝔽}or`n`<-1 _{𝔽}, returnNaN . - If
`n`is1 _{𝔽}, return+∞ _{𝔽}. - If
`n`is-1 _{𝔽}, return-∞ _{𝔽}. - Return an
implementation-approximated value representing the result of the inverse hyperbolic tangent ofℝ (`n`).

# 21.3.2.8 Math.atan2 ( `y`, `x` )

Returns the inverse tangent of the quotient `y` / `x``y` and `x`, where the signs of `y` and `x` are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument inverse tangent function that the argument named `y` be first and the argument named `x` be second. The result is expressed in radians and ranges from -π to +π, inclusive.

When the `Math.atan2`

method is called with arguments `y` and `x`, the following steps are taken:

- Let
`ny`be ?ToNumber (`y`). - Let
`nx`be ?ToNumber (`x`). - If
`ny`isNaN or`nx`isNaN , returnNaN . - If
`ny`is+∞ _{𝔽}, then- If
`nx`is+∞ _{𝔽}, return animplementation-approximated value representing π / 4. - If
`nx`is-∞ _{𝔽}, return animplementation-approximated value representing 3π / 4. - Return an
implementation-approximated value representing π / 2.

- If
- If
`ny`is-∞ _{𝔽}, then- If
`nx`is+∞ _{𝔽}, return animplementation-approximated value representing -π / 4. - If
`nx`is-∞ _{𝔽}, return animplementation-approximated value representing -3π / 4. - Return an
implementation-approximated value representing -π / 2.

- If
- If
`ny`is+0 _{𝔽}, then- If
`nx`>+0 _{𝔽}or`nx`is+0 _{𝔽}, return+0 _{𝔽}. - Return an
implementation-approximated value representing π.

- If
- If
`ny`is-0 _{𝔽}, then- If
`nx`>+0 _{𝔽}or`nx`is+0 _{𝔽}, return-0 _{𝔽}. - Return an
implementation-approximated value representing -π.

- If
Assert :`ny`is finite and is neither+0 _{𝔽}nor-0 _{𝔽}.- If
`ny`>+0 _{𝔽}, then- If
`nx`is+∞ _{𝔽}, return+0 _{𝔽}. - If
`nx`is-∞ _{𝔽}, return animplementation-approximated value representing π. - If
`nx`is+0 _{𝔽}or`nx`is-0 _{𝔽}, return animplementation-approximated value representing π / 2.

- If
- If
`ny`<+0 _{𝔽}, then- If
`nx`is+∞ _{𝔽}, return-0 _{𝔽}. - If
`nx`is-∞ _{𝔽}, return animplementation-approximated value representing -π. - If
`nx`is+0 _{𝔽}or`nx`is-0 _{𝔽}, return animplementation-approximated value representing -π / 2.

- If
Assert :`nx`is finite and is neither+0 _{𝔽}nor-0 _{𝔽}.- Return an
implementation-approximated value representing the result of the inverse tangent of the quotientℝ (`ny`) /ℝ (`nx`).

# 21.3.2.9 Math.cbrt ( `x` )

Returns the cube root of `x`.

When the `Math.cbrt`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - Return an
implementation-approximated value representing the result of the cube root ofℝ (`n`).

# 21.3.2.10 Math.ceil ( `x` )

Returns the smallest (closest to -∞) `x`. If `x` is already an `x`.

When the `Math.ceil`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - If
`n`<+0 _{𝔽}and`n`>-1 _{𝔽}, return-0 _{𝔽}. - If
`n`is anintegral Number , return`n`. - Return the smallest (closest to -∞)
integral Number value that is not less than`n`.

The value of `Math.ceil(x)`

is the same as the value of `-Math.floor(-x)`

.

# 21.3.2.11 Math.clz32 ( `x` )

When the `Math.clz32`

method is called with argument `x`, the following steps are taken:

If `n` is _{𝔽} or `n` is _{𝔽}, this method returns _{𝔽}. If the most significant bit of the 32-bit binary encoding of `n` is 1, this method returns _{𝔽}.

# 21.3.2.12 Math.cos ( `x` )

Returns the cosine of `x`. The argument is expressed in radians.

When the `Math.cos`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`is+∞ _{𝔽}or`n`is-∞ _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the cosine ofℝ (`n`).

# 21.3.2.13 Math.cosh ( `x` )

Returns the hyperbolic cosine of `x`.

When the `Math.cosh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - If
`n`is+0 _{𝔽}or`n`is-0 _{𝔽}, return1 _{𝔽}. - Return an
implementation-approximated value representing the result of the hyperbolic cosine ofℝ (`n`).

The value of `Math.cosh(x)`

is the same as the value of `(Math.exp(x) + Math.exp(-x)) / 2`

.

# 21.3.2.14 Math.exp ( `x` )

Returns the exponential function of `x` (`e` raised to the power of `x`, where `e` is the base of the natural logarithms).

When the `Math.exp`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN or`n`is+∞ _{𝔽}, return`n`. - If
`n`is+0 _{𝔽}or`n`is-0 _{𝔽}, return1 _{𝔽}. - If
`n`is-∞ _{𝔽}, return+0 _{𝔽}. - Return an
implementation-approximated value representing the result of the exponential function ofℝ (`n`).

# 21.3.2.15 Math.expm1 ( `x` )

Returns the result of subtracting 1 from the exponential function of `x` (`e` raised to the power of `x`, where `e` is the base of the natural logarithms). The result is computed in a way that is accurate even when the value of `x` is close to 0.

When the `Math.expm1`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽}, or`n`is+∞ _{𝔽}, return`n`. - If
`n`is-∞ _{𝔽}, return-1 _{𝔽}. - Return an
implementation-approximated value representing the result of subtracting 1 from the exponential function ofℝ (`n`).

# 21.3.2.16 Math.floor ( `x` )

Returns the greatest (closest to +∞) `x`. If `x` is already an `x`.

When the `Math.floor`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - If
`n`<1 _{𝔽}and`n`>+0 _{𝔽}, return+0 _{𝔽}. - If
`n`is anintegral Number , return`n`. - Return the greatest (closest to +∞)
integral Number value that is not greater than`n`.

The value of `Math.floor(x)`

is the same as the value of `-Math.ceil(-x)`

.

# 21.3.2.17 Math.fround ( `x` )

When the `Math.fround`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN , returnNaN . - If
`n`is one of+0 _{𝔽},-0 _{𝔽},+∞ _{𝔽}, or-∞ _{𝔽}, return`n`. - Let
`n32`be the result of converting`n`to a value inIEEE 754-2019 binary32 format using roundTiesToEven mode. - Let
`n64`be the result of converting`n32`to a value inIEEE 754-2019 binary64 format. - Return the ECMAScript
Number value corresponding to`n64`.

# 21.3.2.18 Math.hypot ( ...`args` )

Returns the square root of the sum of squares of its arguments.

When the `Math.hypot`

method is called with zero or more arguments which form the rest parameter ...`args`, the following steps are taken:

- Let
`coerced`be a new emptyList . - For each element
`arg`of`args`, do- Let
`n`be ?ToNumber (`arg`). - Append
`n`to`coerced`.

- Let
- Let
`onlyZero`betrue . - For each element
`number`of`coerced`, do- If
`number`isNaN or`number`is+∞ _{𝔽}, return`number`. - If
`number`is-∞ _{𝔽}, return+∞ _{𝔽}. - If
`number`is neither+0 _{𝔽}nor-0 _{𝔽}, set`onlyZero`tofalse .

- If
- If
`onlyZero`istrue , return+0 _{𝔽}. - Return an
implementation-approximated value representing the square root of the sum of squares of the mathematical values of the elements of`coerced`.

The `hypot`

method is _{𝔽}.

Implementations should take care to avoid the loss of precision from overflows and underflows that are prone to occur in naive implementations when this function is called with two or more arguments.

# 21.3.2.19 Math.imul ( `x`, `y` )

When `Math.imul`

is called with arguments `x` and `y`, the following steps are taken:

# 21.3.2.20 Math.log ( `x` )

Returns the natural logarithm of `x`.

When the `Math.log`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN or`n`is+∞ _{𝔽}, return`n`. - If
`n`is1 _{𝔽}, return+0 _{𝔽}. - If
`n`is+0 _{𝔽}or`n`is-0 _{𝔽}, return-∞ _{𝔽}. - If
`n`<+0 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the natural logarithm ofℝ (`n`).

# 21.3.2.21 Math.log1p ( `x` )

Returns the natural logarithm of 1 + `x`. The result is computed in a way that is accurate even when the value of x is close to zero.

When the `Math.log1p`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽}, or`n`is+∞ _{𝔽}, return`n`. - If
`n`is-1 _{𝔽}, return-∞ _{𝔽}. - If
`n`<-1 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the natural logarithm of 1 +ℝ (`n`).

# 21.3.2.22 Math.log10 ( `x` )

Returns the base 10 logarithm of `x`.

When the `Math.log10`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN or`n`is+∞ _{𝔽}, return`n`. - If
`n`is1 _{𝔽}, return+0 _{𝔽}. - If
`n`is+0 _{𝔽}or`n`is-0 _{𝔽}, return-∞ _{𝔽}. - If
`n`<+0 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the base 10 logarithm ofℝ (`n`).

# 21.3.2.23 Math.log2 ( `x` )

Returns the base 2 logarithm of `x`.

When the `Math.log2`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN or`n`is+∞ _{𝔽}, return`n`. - If
`n`is1 _{𝔽}, return+0 _{𝔽}. - If
`n`is+0 _{𝔽}or`n`is-0 _{𝔽}, return-∞ _{𝔽}. - If
`n`<+0 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the base 2 logarithm ofℝ (`n`).

# 21.3.2.24 Math.max ( ...`args` )

Given zero or more arguments, calls

When the `Math.max`

method is called with zero or more arguments which form the rest parameter ...`args`, the following steps are taken:

- Let
`coerced`be a new emptyList . - For each element
`arg`of`args`, do- Let
`n`be ?ToNumber (`arg`). - Append
`n`to`coerced`.

- Let
- Let
`highest`be-∞ _{𝔽}. - For each element
`number`of`coerced`, do- If
`number`isNaN , returnNaN . - If
`number`is+0 _{𝔽}and`highest`is-0 _{𝔽}, set`highest`to+0 _{𝔽}. - If
`number`>`highest`, set`highest`to`number`.

- If
- Return
`highest`.

The comparison of values to determine the largest value is done using the _{𝔽} is considered to be larger than _{𝔽}.

The `max`

method is _{𝔽}.

# 21.3.2.25 Math.min ( ...`args` )

Given zero or more arguments, calls

When the `Math.min`

method is called with zero or more arguments which form the rest parameter ...`args`, the following steps are taken:

- Let
`coerced`be a new emptyList . - For each element
`arg`of`args`, do- Let
`n`be ?ToNumber (`arg`). - Append
`n`to`coerced`.

- Let
- Let
`lowest`be+∞ _{𝔽}. - For each element
`number`of`coerced`, do- If
`number`isNaN , returnNaN . - If
`number`is-0 _{𝔽}and`lowest`is+0 _{𝔽}, set`lowest`to-0 _{𝔽}. - If
`number`<`lowest`, set`lowest`to`number`.

- If
- Return
`lowest`.

The comparison of values to determine the largest value is done using the _{𝔽} is considered to be larger than _{𝔽}.

The `min`

method is _{𝔽}.

# 21.3.2.26 Math.pow ( `base`, `exponent` )

When the `Math.pow`

method is called with arguments `base` and `exponent`, the following steps are taken:

# 21.3.2.27 Math.random ( )

Returns a _{𝔽} but strictly less than _{𝔽}, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an

Each `Math.random`

function created for distinct realms must produce a distinct sequence of values from successive calls.

# 21.3.2.28 Math.round ( `x` )

Returns the `x` and is integral. If two integral Numbers are equally close to `x`, then the result is the `x` is already integral, the result is `x`.

When the `Math.round`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,+∞ _{𝔽},-∞ _{𝔽}, or anintegral Number , return`n`. - If
`n`<0.5 _{𝔽}and`n`>+0 _{𝔽}, return+0 _{𝔽}. - If
`n`<+0 _{𝔽}and`n`≥-0.5 _{𝔽}, return-0 _{𝔽}. - Return the
integral Number closest to`n`, preferring the Number closer to +∞ in the case of a tie.

`Math.round(3.5)`

returns 4, but `Math.round(-3.5)`

returns -3.

The value of `Math.round(x)`

is not always the same as the value of `Math.floor(x + 0.5)`

. When `x`

is _{𝔽} or is less than _{𝔽} but greater than or equal to _{𝔽}, `Math.round(x)`

returns _{𝔽}, but `Math.floor(x + 0.5)`

returns _{𝔽}. `Math.round(x)`

may also differ from the value of `Math.floor(x + 0.5)`

because of internal rounding when computing `x + 0.5`

.

# 21.3.2.29 Math.sign ( `x` )

Returns the sign of `x`, indicating whether `x` is positive, negative, or zero.

When the `Math.sign`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`<+0 _{𝔽}, return-1 _{𝔽}. - Return
1 _{𝔽}.

# 21.3.2.30 Math.sin ( `x` )

Returns the sine of `x`. The argument is expressed in radians.

When the `Math.sin`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`is+∞ _{𝔽}or`n`is-∞ _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the sine ofℝ (`n`).

# 21.3.2.31 Math.sinh ( `x` )

Returns the hyperbolic sine of `x`.

When the `Math.sinh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - Return an
implementation-approximated value representing the result of the hyperbolic sine ofℝ (`n`).

The value of `Math.sinh(x)`

is the same as the value of `(Math.exp(x) - Math.exp(-x)) / 2`

.

# 21.3.2.32 Math.sqrt ( `x` )

Returns the square root of `x`.

When the `Math.sqrt`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽}, or`n`is+∞ _{𝔽}, return`n`. - If
`n`<+0 _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the square root ofℝ (`n`).

# 21.3.2.33 Math.tan ( `x` )

Returns the tangent of `x`. The argument is expressed in radians.

When the `Math.tan`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, returnNaN . - Return an
implementation-approximated value representing the result of the tangent ofℝ (`n`).

# 21.3.2.34 Math.tanh ( `x` )

Returns the hyperbolic tangent of `x`.

When the `Math.tanh`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽}, or`n`is-0 _{𝔽}, return`n`. - If
`n`is+∞ _{𝔽}, return1 _{𝔽}. - If
`n`is-∞ _{𝔽}, return-1 _{𝔽}. - Return an
implementation-approximated value representing the result of the hyperbolic tangent ofℝ (`n`).

The value of `Math.tanh(x)`

is the same as the value of `(Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x))`

.

# 21.3.2.35 Math.trunc ( `x` )

Returns the integral part of the number `x`, removing any fractional digits. If `x` is already integral, the result is `x`.

When the `Math.trunc`

method is called with argument `x`, the following steps are taken:

- Let
`n`be ?ToNumber (`x`). - If
`n`isNaN ,`n`is+0 _{𝔽},`n`is-0 _{𝔽},`n`is+∞ _{𝔽}, or`n`is-∞ _{𝔽}, return`n`. - If
`n`<1 _{𝔽}and`n`>+0 _{𝔽}, return+0 _{𝔽}. - If
`n`<+0 _{𝔽}and`n`>-1 _{𝔽}, return-0 _{𝔽}. - Return the
integral Number nearest`n`in the direction of+0 _{𝔽}.