API Reference
Classes
Math
Utility class for mathematical operations.
Static Functions
Name | Description |
---|---|
| Returns the absolute value of a number. |
| Returns the inverse cosine (in radians) of a number. |
| Calculates the inverse cotangent (acot) of a number. |
| Calculates the inverse cosecant (acsc) of a number. |
| Calculates the mean value of an array of numbers. |
| Calculates the inverse secant (asec) of a number. |
| Returns the inverse sine (in radians) of a number. |
| Returns the inverse tangent (in radians) of a number. |
| Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x). |
| Returns the smallest integer greater than or equal to a given number. |
| Calculates the number of combinations for choosing r items from a total of n items. |
| Returns the cosine of a number in radians. |
| Calculates the cotangent of an angle (in radians). |
| Calculates the cosecant of an angle (in radians). |
| Convert degrees to radians. |
| Calculates the factorial of a given number. |
| Calculates the nth Fibonacci number. |
| Returns the largest integer less than or equal to a given number. |
| Calculates the geometric mean of an array of numbers. |
| Calculates the harmonic mean of an array of numbers. |
| Calculate the length of the vector from the origin to the point given by the coordinates. |
| Checks if a number is prime. |
| Returns the natural logarithm (base e) of a number. |
| Returns the base-10 logarithm of a number. |
| Returns the base-2 logarithm of a number. |
| Returns the maximum value from an array of numbers. |
| Calculates the median value of an array of numbers. |
| Returns the minimum value from an array of numbers. |
| Calculates the mode values of an array of numbers. |
| Convert radians to degrees. |
| Generates a pseudo-random number between 0 and max (default of 1). |
| Rounds the given number to the nearest integer. |
| Calculates the secant of an angle (in radians). |
| Returns 1 or -1, indicating the sign of the number passed as an argument, 0 for 0. |
| Returns the sine of a number in radians. |
| Returns the square root of a number. |
| Returns the tangent of a number in radians. |
| Convert a value to a new number base. |
abs
bring math;
math.abs(value: num);
Returns the absolute value of a number.
value
Required
- Type: num
The input number.
acos
bring math;
math.acos(value: num);
Returns the inverse cosine (in radians) of a number.
value
Required
- Type: num
A number between -1 and 1, inclusive, representing the angle's cosine value.
acot
bring math;
math.acot(value: num);
Calculates the inverse cotangent (acot) of a number.
value
Required
- Type: num
A number representing the cotangent value.
acsc
bring math;
math.acsc(value: num);
Calculates the inverse cosecant (acsc) of a number.
value
Required
- Type: num
A number equal or greater than |1|, representing the cosecant value.
arithmeticMean
bring math;
math.arithmeticMean(arr: MutArray<num>);
Calculates the mean value of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
asec
bring math;
math.asec(value: num);
Calculates the inverse secant (asec) of a number.
value
Required
- Type: num
A number equal or greater than |1|, representing the secant value.
asin
bring math;
math.asin(value: num);
Returns the inverse sine (in radians) of a number.
value
Required
- Type: num
A number between -1 and 1, inclusive, representing the angle's sine value.
atan
bring math;
math.atan(value: num);
Returns the inverse tangent (in radians) of a number.
value
Required
- Type: num
A number.
atan2
bring math;
math.atan2(y: num, x: num);
Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x).
y
Required
- Type: num
The y coordinate of the point.
x
Required
- Type: num
The x coordinate of the point.
ceil
bring math;
math.ceil(value: num);
Returns the smallest integer greater than or equal to a given number.
value
Required
- Type: num
The input number.
combinations
bring math;
math.combinations(n: num, r: num);
Calculates the number of combinations for choosing r items from a total of n items.
n
Required
- Type: num
The total number of items.
r
Required
- Type: num
The number of items to be chosen.
cos
bring math;
math.cos(value: num);
Returns the cosine of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
cot
bring math;
math.cot(value: num);
Calculates the cotangent of an angle (in radians).
value
Required
- Type: num
The angle in radians.
csc
bring math;
math.csc(value: num);
Calculates the cosecant of an angle (in radians).
value
Required
- Type: num
The angle in radians.
degreesToRadians
bring math;
math.degreesToRadians(degrees: num);
Convert degrees to radians.
degrees
Required
- Type: num
Degree value.
factorial
bring math;
math.factorial(n: num);
Calculates the factorial of a given number.
n
Required
- Type: num
The number to calculate the factorial for.
fibonacci
bring math;
math.fibonacci(n: num);
Calculates the nth Fibonacci number.
n
Required
- Type: num
The position of the Fibonacci number to calculate.
floor
bring math;
math.floor(value: num);
Returns the largest integer less than or equal to a given number.
value
Required
- Type: num
The input number.
geometricMean
bring math;
math.geometricMean(arr: MutArray<num>);
Calculates the geometric mean of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
harmonicMean
bring math;
math.harmonicMean(arr: MutArray<num>);
Calculates the harmonic mean of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
hypot
bring math;
math.hypot(coordinates: MutArray<num>);
Calculate the length of the vector from the origin to the point given by the coordinates.
coordinates
Required
- Type: MutArray<num>
Array of coordinates.
isPrime
bring math;
math.isPrime(n: num);
Checks if a number is prime.
n
Required
- Type: num
The number to check for primality.
log
bring math;
math.log(value: num);
Returns the natural logarithm (base e) of a number.
value
Required
- Type: num
The input number.
log10
bring math;
math.log10(value: num);
Returns the base-10 logarithm of a number.
value
Required
- Type: num
The input number.
log2
bring math;
math.log2(value: num);
Returns the base-2 logarithm of a number.
value
Required
- Type: num
The input number.
max
bring math;
math.max(arr: MutArray<num>);
Returns the maximum value from an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
median
bring math;
math.median(arr: MutArray<num>);
Calculates the median value of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
min
bring math;
math.min(arr: MutArray<num>);
Returns the minimum value from an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
mode
bring math;
math.mode(arr: MutArray<num>);
Calculates the mode values of an array of numbers.
arr
Required
- Type: MutArray<num>
The array of numbers.
radiansToDegrees
bring math;
math.radiansToDegrees(radians: num);
Convert radians to degrees.
radians
Required
- Type: num
Radians value.
random
bring math;
math.random(max?: num);
Generates a pseudo-random number between 0 and max (default of 1).
max
Optional
- Type: num
The maximum value of the random number.
round
bring math;
math.round(value: num, options?: RoundingOptions);
Rounds the given number to the nearest integer.
value
Required
- Type: num
The number to be rounded.
options
Optional
- Type: RoundingOptions
sec
bring math;
math.sec(value: num);
Calculates the secant of an angle (in radians).
value
Required
- Type: num
The angle in radians.
sign
bring math;
math.sign(value: num);
Returns 1 or -1, indicating the sign of the number passed as an argument, 0 for 0.
value
Required
- Type: num
The input number.
sin
bring math;
math.sin(value: num);
Returns the sine of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
sqrt
bring math;
math.sqrt(value: num);
Returns the square root of a number.
value
Required
- Type: num
A number greater than or equal to 0.
tan
bring math;
math.tan(value: num);
Returns the tangent of a number in radians.
value
Required
- Type: num
A number representing an angle in radians.
toRadix
bring math;
math.toRadix(value: num, base: num);
Convert a value to a new number base.
value
Required
- Type: num
The number to be converted.
base
Required
- Type: num
The base of the new value.
Constants
Name | Type | Description |
---|---|---|
| num | Euler's number, a mathematical constant approximately equal to 2.71828. |
| num | Positive infinity constant. |
| num | The mathematical constant representing the ratio of a circle's circumference to its diameter. |
| num | The mathematical constant representing the ratio of a circle's circumference to the radius. |
E
Required
E: num;
- Type: num
Euler's number, a mathematical constant approximately equal to 2.71828.
INF
Required
INF: num;
- Type: num
Positive infinity constant.
PI
Required
PI: num;
- Type: num
The mathematical constant representing the ratio of a circle's circumference to its diameter.
TAU
Required
TAU: num;
- Type: num
The mathematical constant representing the ratio of a circle's circumference to the radius.
Structs
RoundingOptions
Options for rounding a number.
Initializer
bring math;
let RoundingOptions = math.RoundingOptions{ ... };
Properties
Name | Type | Description |
---|---|---|
| num | The number of decimal places to round to. |
decimalPlaces
Optional
decimalPlaces: num;
- Type: num
The number of decimal places to round to.