# JavaScriptMath: Object

Contains math related constants and functions.

## Math Properties

E : Number

The constant e = 2.718...

Run

#### Results:

` `

LN10 : Number

The value of the natural log of 10. It is the reciprocal of `LOG10E`. Useful for computing the log base 10 of a number. See also `log10()`.

Run

#### Results:

` `

LN2 : Number

The value of the natural log of 2. It is the reciprocal of `LOG2E`. Useful for computing the log base 2 of a number. See also `log2()`.

Run

#### Results:

` `

LOG10E : Number

The value of the log base 10 of e. It is the reciprocal of `LN10`. Useful for computing the log base 10 of a number. See also `log10()`.

Run

#### Results:

` `

LOG2E : Number

The value of the log base 2 of e. It is the reciprocal of `LN2`. Useful for computing the log base 2 of a number. See also `log2()`.

Run

#### Results:

` `

PI : Number

The constant pi = 3.14...

Run

#### Results:

` `

SQRT1_2 : Number

The value of `1 / sqrt(2)`.

Run

#### Results:

` `

SQRT2 : Number

The value of `sqrt(2)`.

Run

` `

## Math Methods

abs(x : Number) : Number

Returns the absolute value of `x`.

Run

#### Results:

` `

acos(x : Number) : Number

Returns the angle (in radians between 0 and pi) whose cosine is `x`. See also `cos()`.

Run

#### Results:

` `

acosh(x : Number) : Number

Returns the hyperbolic angle whose hyperbolic cosine is `x`. See also `cosh()`.

Run

#### Results:

` `

asin(x : Number) : Number

Returns the angle (in radians between -pi/2 and pi/2) whose sine is `x`. See also `sin()`.

Run

#### Results:

` `

asinh(x : Number) : Number

Returns the hyperbolic angle whose hyperbolic sine is `x`. See also `sinh()`.

Run

#### Results:

` `

atan(x : Number) : Number

Returns the angle (in radians between -pi/2 and pi/2) whose tangent is `x`. See also `atan2()` and `tan()`.

Run

#### Results:

` `

atan2(y : Number, x : Number) : Number

Returns the angle (in radians between -pi and pi) between the positive x axis and the line segment from the origin to the point at (`x`, `y`). See also `atan()` and `tan()`.

Run

#### Results:

` `

atanh(x : Number) : Number

Returns the hyperbolic angle whose hyperbolic tangent is `x`. See also `tanh()`.

Run

#### Results:

` `

cbrt(x : Number) : Number

Returns cube root of `x`.

Run

#### Results:

` `

ceil(x : Number) : Number

Returns the next integer greater than or equal to `x`. See also `round()`, `floor()`, and `trunc()`.

Run

#### Results:

` `

clz(x : Number) : Number

Returns the number of leading `0` bits in the 32 bit unsigned integer representation of `x`.

Run

#### Results:

` `

cos(x : Number) : Number

Returns the cosine of `x` (in radians). See also `acos()`.

Run

#### Results:

` `

cosh(x : Number) : Number

Returns the hyperbolic cosine of `x`. See also `acosh()`.

Run

#### Results:

` `

exp(x : Number) : Number

Returns e raised to the `x` power. See also `log()` and `expm1()`.

Run

#### Results:

` `

expm1(x : Number) : Number

Returns e raised to the `x` power minus 1. This is more accurate than using `exp(x) - 1` when `x` is close to `0`.

Run

#### Results:

` `

floor(x : Number) : Number

Returns the previous integer less than or equal to `x`. See also `round()`, `ceil()`, and `trunc()`.

Run

#### Results:

` `

fround(x : Number) : Number

Returns the closest single precision (32 bit) floating point number to `x`.

Run

#### Results:

` `

hypot(x : Number, y : Number, [z : Number, [...]]) : Number

Returns length of a vector with components [`x`, `y`, ...]. This is the square root of the sum of the squares of the components.

Run

#### Results:

` `

imul(x : Number, y : Number) : Number

Returns the product of `x` and `y` treating both values as 32 bit integer values and truncating the result to a 32 bit integer value.

Run

#### Results:

` `

log(x : Number) : Number

Returns the natural logarithm (base e) of `x`. To compute the logarithm with respect to a different base `b`, use the formula `Math.log(x) / Math.log(b)`. For base 10, you can use `Math.log(x) * Math.LOG10E` (or `log10()` with ECMAScript 2015). For base 2, you can use `Math.log(x) * Math.LOG2E` (or `log2()` with ECMAScript 2015). See also `exp()` and `log1p()`.

Run

#### Results:

` `

log10(x : Number) : Number

Returns the base 10 logarithm of `x`. See also `log()`, `LOG10E`, and `LN10`.

Run

#### Results:

` `

log1p(x : Number) : Number

Returns the natural logarithm (base e) of `x + 1`. This is more accurate than using `log(x + 1)` when `x` is close to `0`.

Run

#### Results:

` `

log2(x : Number) : Number

Returns the base 2 logarithm of `x`. See also `log()`, `LOG2E`, and `LN2`.

Run

#### Results:

` `

max(x1 : Number, x2 : Number, [...]) : Number

Returns the largest number among the parameters.

Run

#### Results:

` `

min(x1 : Number, x2 : Number, [...]) : Number

Returns the smallest number among the parameters.

Run

#### Results:

` `

pow(x : Number, y : Number) : Number

Returns `x` raised to the `y` power.

Run

#### Results:

` `

random() : Number

Returns a random number between `0` (inclusive) and `1` (exclusive).

Run

#### Results:

` `

round(x : Number) : Number

Returns the closest integer to `x`. See also `floor()`, `ceil()`, and `trunc()`.

Run

#### Results:

` `

sign(x : Number) : Number

Returns `-1` if `x` is less than `0`, `0` if `x` is `0`, and `1` if `x` is greater than `0`.

Run

#### Results:

` `

sin(x : Number) : Number

Returns the sine of `x` (in radians). See also `asin()`.

Run

#### Results:

` `

sinh(x : Number) : Number

Returns the hyperbolic sine of `x`. See also `asinh()`.

Run

#### Results:

` `

sqrt(x : Number) : Number

Returns the square root of `x`.

Run

#### Results:

` `

tan(x : Number) : Number

Returns the tangent of `x` (in radians). See also `atan()`.

Run

#### Results:

` `

tanh(x : Number) : Number

Returns the hyperbolic tan of `x`. See also `atanh()`.

Run

#### Results:

` `

trunc(x : Number) : Number

Returns the integer portion of `x`. This is the same as `floor(x)` for positive numbers and `ceil(x)` for negative numbers. See also `round()`.

Run

` `