Skip to content

Math

The math package provides a series of mathematical functions.

Function NameDescription
abs(n: number): numberReturns the absolute value of n
acos(n: number): numberReturns the arccosine of n
asin(n: number): numberReturns the arcsine of n
atan(n: number): numberReturns the arctangent of n
ceiling(n: number): numberReturns the smallest integer greater than or equal to n
floor(n: number): numberReturns the largest integer less than or equal to n
round(n: number): numberRounds n to the nearest integer
cos(n: number): numberReturns the cosine of n
exp(n: number): numberReturns e raised to the power of n
fracpart(n: number): numberReturns the fractional part of n
intpart(n: number): numberReturns the integer part of n
ln(n: number): numberReturns the natural logarithm (base e) of n
log(n: number): numberReturns the logarithm (base 10) of n
sin(n: number): numberReturns the sine of n in radians
sqrt(n: number): numberReturns the square root of n
tan(n: number): numberReturns the tangent of n
max(n1: number?, n2: number?, ...): numberReturns the largest value among the input parameters
min(n1: number?, n2: number?, ...): numberReturns the smallest value among the input parameters
mod(n: number): numberReturns the remainder of a divided by b
pow(n: number): numberReturns a raised to the power of b
reverse(n: number): number[Deprecated] Changes the sign of n
sgn(n: number): number, sign(n: number): number[Deprecated] Returns the sign of n. If n > 0, returns 1; if n = 0, returns 0; if n < 0, returns -1
isnil(n: number): boolReturns true if n is NAN, +INF, or -INF; otherwise, returns false