Mathematical Functions
abs
abs(number)
abs(-1) // => 1
Description
Returns the absolute value of a number.
Return type
Number
sqrt
sqrt(number)
sqrt(9) // => 3
sqrt(10) // => 3.1622776601683795
Description
Returns the square root of a number.
Return type
Number
ceil
ceil(number)
ceil(1.1) // => 2
ceil(1.9) // => 2
Description
Returns the smallest integer greater than or equal to a number.
Return type
Number
floor
floor(number)
floor(1.1) // => 1
floor(1.9) // => 1
Description
Returns the largest integer less than or equal to a number.
Return type
Number
round
round(number)
round(number, scale)
round(1.1) // => 1
round(1.1, 0) // => 1
round(1.9, 0) // => 2
round(1.12345, 2) // => 1.12
round(-1.5) // => -2
Description
Returns the rounded value of a number to a specified number of decimal places (scale). Round away from zero if the fractional part of the number is greater than 0.5; otherwise, round towards zero.
Return type
Number
trunc
trunc(number)
trunc(number, scale)
trunc(1.1) // => 1
trunc(1.1, 0) // => 1
trunc(1.9, 0) // => 1
trunc(1.12345, 2) // => 1.12
Description
Returns the truncated value of a number to a specified number of decimal places (scale).
Return type
Number
exp
exp(number)
exp(1) // => 2.718281828459045
Description
Returns the value of the constant raised to the power of a number.
Return type
Number
ln
ln(number)
ln(1) // => 0
Description
Returns the natural logarithm () of a number.
Return type
Number
log10
log10(number)
log10(100) // => 2
Description
Returns the base 10 logarithm () of a number.
Return type
Number
log2
log2(number)
log2(8) // => 3
Description
Returns the base 2 logarithm () of a number.
Return type
Number
pow
pow(base, exponent)
pow(2, 3) // => 8
Description
Returns the value of a base raised to the power of an exponent.
Return type
Number
mod
mod(dividend, divisor)
mod(5, 2) // => 1
Description
Returns the remainder of a division operation.
Return type
Number
div
div(dividend, divisor)
div(5, 2) // => 2
Description
Returns the integer quotient of a division operation.
Return type
Number
sign
sign(number)
sign(5) // => 1
sign(-5) // => -1
sign(0) // => 0
Description
Returns the sign of a number: 1 if the number is positive, -1 if the number is negative, and 0 if the number is zero.
Return type
Number
radians
radians(degrees)
radians(180) // => 3.141592653589793
Description
Converts degrees to radians.
Return type
Number
degrees
degrees(radians)
degrees(pi()) // => 180
Description
Converts radians to degrees.
Return type
Number
pi
pi()
pi() // => 3.141592653589793
Description
Returns the value of the constant .
Return type
Number
acos
acos(number)
acos(cos(pi())) // => 3.141592653589793
Description
Returns the arccosine of a number.
Return type
Number
asin
asin(number)
asin(sin(pi() / 2)) // => 1.5707963267948966
Description
Returns the arcsine of a number.
Return type
Number
atan
atan(number)
atan(tan(pi() / 4)) // => 0.7853981633974483
Description
Returns the arctangent of a number.
Return type
Number
atan2
atan2(y, x)
atan2(2, pi()) // => 0.6366197723675814
**Description**
Returns the 2-argument arctangent.
**Return type**
Number
### cos
```jsx
cos(number)
cos(pi()) // => -1
Description
Returns the cosine of a number.
Return type
Number
sin
sin(number)
sin(pi() / 2) // => 1
Description
Returns the sine of a number.
Return type
Number
tan
tan(number)
tan(pi() / 4) // => 1
Description
Returns the tangent of a number.
Return type
Number
cot
cot(number)
cot(pi() / 4) // => 1
Description
Returns the cotangent of a number.
Return type
Number