xtr.math¶
abs¶
abs(num: Number): Number
Returns the absolute value of the given num
.
Example
Resultacos¶
acos(num: Number): Number
Returns the arc cosine of the given num
.
Example
Resultasin¶
asin(num: Number): Number
Returns the arc sine of the given num
.
Example
Resultatan¶
atan(num: Number): Number
Returns the arc tangent of the given num
.
Example
Resultavg¶
avg(arr: Array[Number]): Number
Returns the average of the numbers in arr
.
Example
Resultceil¶
ceil(num: Number): Number
Returns the ceiling (aka round up) of the given num
.
Example
Resultclamp¶
clamp(num: Number, min: Number, max: Number): Number
Returns num
if it exists between min
and max
, otherwise the one that is closest.
Example
Resultcos¶
cos(num: Number): Number
Returns the cosine of the givennum
.
Example
Resultexp¶
exp(num: Number): Number
Returns Euler's number e, to the power of num
.
Example
Resultexponent¶
exponent(num: Number): Number
Returns the exponent portion of the double-precision binary floating-point representation (IEEE 754:binary64) of the given num
.
Example
Resultfloor¶
floor(num: Number): Number
Returns the floor (aka round down) of the given num
.
Example
Resultlog¶
log(num: Number): Number
Returns the natural logarithm of the given num
.
Example
Resultmantissa¶
mantissa(num: Number): Number
Returns the fraction portion (aka significand) of the double-precision binary floating-point representation (IEEE 754:binary64) of the given num
.
Example
Resultpow¶
pow(num: Number1, num: Number2)
Returns the value of num1
raised to the power of num2
.
Example
Resultrandom¶
random
Returns a pseudo-random double-precision floating-point number between 0
and 1
.
Example
ResultrandomInt¶
randomInt(num: Number): Number
Returns a pseudo-random integer between 0 (inclusive) and the givennum
(exclusive).
Example
Resultround¶
round(num: Number, mode: String = 'half-up', precision: Number = '0'): Number
Rounds the given num
using the mode
and precision
requested. Supported modes are up
, down
, half-up
, half-down
, ceiling
, floor
, and half-even
.
Example
Resultsin¶
sin(num: Number): Number
Returns the sine of the given num
.
Example
Resultsqrt¶
sqrt(num: Number): Number
Returns the square root of the given num
.
Example
Resultsum¶
sum(arr: Array[Number])
Returns the sum of all numbers in arr
.
Example
Resulttan¶
tan(num: Number): Number
Returns the tangent of the given num
.
Example
Result