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