Common maths functions
Functions
abs(x) → {number}
The abs() function returns the absolute value of a number.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. A number |
Returns:
- Type:
- number
A Number, representing the absolute value of the specified number
ceiling(x) → {number}
The ceiling() function rounds a number UPWARDS to the nearest integer, and returns the result.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. The number you want to round |
Returns:
- Type:
- number
A Number, representing the nearest integer when rounding upwards
floor(x) → {number}
The floor() function rounds a number DOWNWARDS to the nearest integer, and returns the result.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. The number you want to round |
Returns:
- Type:
- number
A Number, representing the nearest integer when rounding downwards
ln() → {number}
The ln function returns the natural logarithm of 2, approximately 0.693.
Returns:
- Type:
- number
A Number, representing the natural logarithm of 2
log(x) → {number}
The log() function returns the natural logarithm (base E) of a number.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. A number |
Returns:
- Type:
- number
A Number, representing the natural logarithm of a specified number
mod(x, y) → {number}
The mod function returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. The dividend |
y |
number |
Required. The divisor |
Returns:
- Type:
- number
A Number, the division remainder
pi() → {number}
The PI function returns the ratio of a circle's area to the square of its radius, approximately 3.14
Returns:
- Type:
- number
A Number, representing PI
pow(x, y) → {number}
The pow() function returns the value of x to the power of y
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. The base |
y |
number |
Required. The exponent |
Returns:
- Type:
- number
A Number, representing the value of x to the power of y.
random() → {number}
The random() function returns a random number from 0 (inclusive) up to but not including 1 (exclusive).
Returns:
- Type:
- number
A Number, representing a number from 0 up to but not including 1
round(x) → {number}
The round() function rounds a number to the nearest integer.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. The number to be rounded |
Returns:
- Type:
- number
A number, representing the nearest integer
sqrt(x) → {number}
The sqrt() function returns the square root of a number.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Required. A number |
Returns:
- Type:
- number
A Number. If x is a negative number, NaN is returned