← Reference

Math

Math object for mathematical functions and constants.

Math.abs()

Returns the absolute value of a number.

abs(x)

Math.ceil()

Return the smallest integer greater than or equal to a number.

Math.ceil(x)

Math.clz32()

Returns the number of leading zero bits in the 32-bit binary representation of a number.

Math.clz32(x)

Math.E

The base of natural logarithms, approximately 2.718281828459045. Used as the base for Math.log() and exponential calculations.

Math.exp()

Returns e raised to the power of a given number, where e is the base of the natural logarithm (approximately 2.71828).

Math.exp(x)

Math.floor()

Return the largest integer less than or equal to a number.

floor(x)

Math.fround()

Returns the nearest 32-bit single precision float representation of a number.

Math.fround(x)

Math.LN10

The natural logarithm of 10, approximately 2.302585092994046. A read-only constant on the Math object.

Math.LN2

The natural logarithm of 2, approximately 0.6931471805599453. Used in logarithmic and exponential calculations.

Math.log()

Returns the natural logarithm (base e) of a number, where e is approximately 2.718281828459045.

Math.log(x)

Math.log10()

Calculate the base-10 logarithm of a number. Essential for data science, magnitude calculations, and digit counting.

Math.log10(x)

Math.LOG10E

The base-10 logarithm of E, approximately 0.4342944819032518. Useful for converting between natural and decimal logarithms.

Math.log1p()

Returns the natural logarithm (base e) of 1 + a given number, computed in a way that is more accurate when the number is close to zero.

Math.log1p(x)

Math.log2()

Calculate the base-2 logarithm of a number. Essential for binary algorithms, bit depth calculations, and understanding computational complexity.

Math.log2(x)

Math.LOG2E

The base-2 logarithm of E, approximately 1.4426950408889634. Represents log2(e) for logarithmic calculations.

Math.max()

Returns the largest of zero or more numbers given as input parameters.

Math.max(value1, value2, ...values)

Math.min()

Return the lowest of zero or more numbers. Learn how Math.min() handles empty arguments, NaN, and how it compares to Math.max().

Math.min([value1[, value2[, ...]]])

Math.PI

The ratio of a circle's circumference to its diameter, approximately 3.141592653589793. A read-only constant on the Math object.

Math.pow()

Raise a number to a power. Learn how Math.pow() handles integers, decimals, special values like NaN and Infinity, and how it differs from the ** exponentiati...

Math.pow(base, exponent)

Math.round()

Round a number to the nearest integer. Learn how Math.round() handles .5 cases, negative numbers, and how it differs from Math.floor(), Math.ceil(), and Math...

Math.round(x)

Math.sign()

Return the sign of a number indicating whether it's positive, negative, or zero. Essential for direction detection in games, physics simulations, and normali...

Math.sign(x)

Math.sqrt()

Returns the square root of a given number. Returns NaN for negative numbers.

Math.sqrt(x)

Math.SQRT1_2

The square root of 1/2, approximately 0.7071067811865476. Used in trigonometry, geometry, and normalization calculations.

Math.SQRT2

The square root of 2, approximately 1.4142135623730951. Used in geometry, scaling, and mathematical algorithms.

Math.trunc()

Remove fractional digits from a number. Learn how Math.trunc() differs from Math.floor(), Math.round(), and bitwise alternatives.

Math.trunc(x)