Link Search Menu Expand Document

Arithmetic

arithmetic.ts#L217

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  
arithmetic.ts#L232

cube (x: number): number

Cubes a number.

Name Type Default Description
x number    
arithmetic.ts#L175

digits (n: number): Array<number>

Returns the digits of a number n.

Name Type Default Description
n number    
arithmetic.ts#L25

isBetween (x: number, a: number, b: number, t: number): boolean

Checks if a number x is between two numbers a and b.

Name Type Default Description
x number    
a number    
b number    
t number  
arithmetic.ts#L20

isInteger (x: number, t: number): boolean

Name Type Default Description
x number    
t number  
arithmetic.ts#L222

lerp (a: number, b: number, t: number): number

Linear interpolation

Name Type Default Description
a number    
b number    
t number 0.5  
arithmetic.ts#L246

log (x: number, b: number): number

Calculates the logarithm of x with base b.

Name Type Default Description
x number    
b number    
arithmetic.ts#L241

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    
arithmetic.ts#L14

nearlyEquals (x: number, y: number, t: number): boolean

Checks if two numbers are nearly equals.

Name Type Default Description
x number    
y number    
t number  
arithmetic.ts#L69

numberFormat (n: number, places: number, seperators: boolean): string

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  
seperators boolean true  
arithmetic.ts#L89

parseNumber (str: string): number

Converts a number to a string, including . or , decimal points and thousands separators.

Name Type Default Description
str string    
arithmetic.ts#L257

polynomial (x: number, coefficients: Array<number>): number

Name Type Default Description
x number    
coefficients Array<number>    
arithmetic.ts#L251

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    
arithmetic.ts#L181

round (n: number, precision: number): number

Rounds a number n to precision decimal places.

Name Type Default Description
n number    
precision number 0  
arithmetic.ts#L187

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  
arithmetic.ts#L31

sign (x: number, t: number): 1|0|-1

Returns the sign of a number x, as +1, 0 or –1.

Name Type Default Description
x number    
t number  
arithmetic.ts#L227

square (x: number): number

Squares a number.

Name Type Default Description
x number    
arithmetic.ts#L195

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  
arithmetic.ts#L113

toOrdinal (x: number): string

Converts a number to an ordinal.

Name Type Default Description
x number    
arithmetic.ts#L152

toWord (n: number): string

Spells a number as an English word.

Name Type Default Description
n number    

Copyright © 2021 Mathigon.org