Arithmetic clamp (x: number, min: number, max: number): number Bounds a number between a lower and an upper limit.
Name Type Default Description x
number min
number -Infinity max
number …
cube (x: number): number Cubes a number.
Name Type Default Description x
number
digits (n: number): Array<number> Returns the digits of a number n.
Name Type Default Description n
number
isBetween (value: number, a: number, b: number, t: number): boolean Checks if a number x is between two numbers a and b.
Name Type Default Description value
number a
number b
number t
number …
isInteger (x: number, t: number): boolean Name Type Default Description x
number t
number …
lerp (a: number, b: number, t: number): number Linear interpolation
Name Type Default Description a
number b
number t
number 0.5
log (x: number, b: number): number Calculates the logarithm of x
with base b
.
Name Type Default Description x
number b
number
mod (a: number, m: number): number Calculates a mod m
. The JS implementation of the % operator returns the symmetric modulo. Both are identical if a >= 0 and m >= 0 but the results differ if a or m < 0.
Name Type Default Description a
number m
number
nearlyEquals (a: number, b: number, t: number): boolean Checks if two numbers are nearly equals.
Name Type Default Description a
number b
number t
number …
Converts a number to a clean string, by rounding, adding power suffixes, and adding thousands separators. places
is the number of digits to show in the result.
Name Type Default Description n
number places
number 0 separators
boolean true
parseNumber (str: string): number Converts a number to a string, including . or , decimal points and thousands separators.
Name Type Default Description str
string
polynomial (x: number, coefficients: Array<number>): number Name Type Default Description x
number coefficients
Array<number>
quadratic (a: number, b: number, c: number): Array<number> Solves the quadratic equation a x^2 + b x + c = 0
Name Type Default Description a
number b
number c
number
round (n: number, precision: number): number Rounds a number n
to precision
decimal places.
Name Type Default Description n
number precision
number 0
roundTo (n: number, increment: number): number Round a number n
to the nearest multiple of increment
.
Name Type Default Description n
number increment
number 1
sign (value: number, t: number): 1|0|-1 Returns the sign of a number x, as +1, 0 or –1.
Name Type Default Description value
number t
number …
square (x: number): number Squares a number.
Name Type Default Description x
number
toFraction (decimal: number, precision: number): Array<number> Returns an [numerator, denominator] array that approximated a decimal
to precision
. See http://en.wikipedia.org/wiki/Continued_fraction
Name Type Default Description decimal
number precision
number …
toOrdinal (x: number): string Converts a number to an ordinal.
Name Type Default Description x
number
toWord (n: number): string Spells a number as an English word.
Name Type Default Description n
number