@jdeurt/math.ts
v2.0.0
Published
Utility types for numbers.
Readme
@jdeurt/math.ts
Utility types for numbers.
Installation
npm install @jdeurt/math.tsAPI
Number types passed to any of the following utility types are casted to integers. For example, Add<5, 3.5> will return 8.
int A, int B => Add A B -> int
Adds integers A and B and returns the result.
type Result = Add<5, 3>; // 8int A, int B => Sub A B -> int
Subtracts integer B from A and returns the result.
type Result = Sub<5, 3>; // 2int A, int B => Mul A B -> int
Multiplies integers A and B and returns the result.
type Result = Mul<5, 3>; // 15int A, int B => Div A B -> int
Divides integer A by integer B and returns the result.
type Result = Div<10, 2>; // 5int A, int B => Mod A B -> int
Finds the modulus of integer A by B and returns the result.
type Result = Mod<10, 3>; // 1int A, int B => Pow A B -> int
Raises integer A to the power of B and returns the result.
type Result = Pow<2, 3>; // 8int A, int B => Eq A B -> int
Checks if integer A is equal to B and returns 1 if true, otherwise 0.
type Result = Eq<5, 5>; // 1int A, int B => Gt A B -> int
Checks if integer A is greater than B and returns 1 if true, otherwise 0.
type Result = Gt<5, 3>; // 1int A, int B => Lt A B -> int
Checks if integer A is less than B and returns 1 if true, otherwise 0.
type Result = Lt<5, 7>; // 1int A, int B => Gte A B -> int
Checks if integer A is greater than or equal to B and returns 1 if true, otherwise 0.
type Result = Gte<5, 5>; // 1int A, int B => Lte A B -> int
Checks if integer A is less than or equal to B and returns 1 if true, otherwise 0.
type Result = Lte<5, 7>; // 1License
MIT © Juan de Urtubey
