Number Functions
This module provides a collection of utility functions for working with numbers. It extends functionality from the Effect-TS library.
Arithmetic Operations
sum(self: number, that: number): number
Returns the sum of two numbers.
typescriptsum(5, 3); // returns 8
subtract(self: number, that: number): number
Returns the difference between two numbers.
typescriptsubtract(5, 3); // returns 2
multiply(self: number, that: number): number
Returns the product of two numbers.
typescriptmultiply(5, 3); // returns 15
divide(self: number, that: number): number
Returns the quotient of two numbers.
typescriptdivide(6, 2); // returns 3
remainder(self: number, that: number): number
Returns the remainder after division of two numbers. The result takes the sign of the dividend.
typescriptremainder(5, 2); // returns 1 remainder(-5, 2); // returns -1
Number Transformations
abs(self: number): number
Returns the absolute value of a number.
typescriptabs(-5); // returns 5 abs(5); // returns 5
round(self: number, precision: number): number
Rounds a number to the specified precision (decimal places).
typescriptround(3.14159, 2); // returns 3.14 round(3.14159, 0); // returns 3
Comparison Operations
greaterThan(self: number, that: number): boolean
Checks if the first number is greater than the second.
typescriptgreaterThan(5, 3); // returns true greaterThan(3, 5); // returns false
lessThan(self: number, that: number): boolean
Checks if the first number is less than the second.
typescriptlessThan(3, 5); // returns true lessThan(5, 3); // returns false
lessThanOrEqualTo(self: number, that: number): boolean
Checks if the first number is less than or equal to the second.
typescriptlessThanOrEqualTo(3, 3); // returns true lessThanOrEqualTo(3, 5); // returns true lessThanOrEqualTo(5, 3); // returns false
greaterThanOrEqualTo(self: number, that: number): boolean
Checks if the first number is greater than or equal to the second.
typescriptgreaterThanOrEqualTo(5, 3); // returns true greaterThanOrEqualTo(3, 3); // returns true greaterThanOrEqualTo(3, 5); // returns false
equals(self: number, that: number): boolean
Checks if two numbers are strictly equal.
typescriptequals(5, 5); // returns true equals(5, 3); // returns false