(divisor: number): (self: number) => number
(self: number, divisor: number): numberReturns the remainder left over when one operand is divided by a second operand, always taking the sign of the dividend.
When to use
Use to compute a numeric remainder while preserving decimal precision better
than direct JavaScript % for decimal operands.
Example (Calculating remainders)
import { Number } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Number.remainder(2, 2), 0)
assert.deepStrictEqual(Number.remainder(3, 2), 1)
assert.deepStrictEqual(Number.remainder(-4, 2), -0)export const const remainder: {
(divisor: number): (self: number) => number
(self: number, divisor: number): number
}
Returns the remainder left over when one operand is divided by a second operand, always taking the sign of the dividend.
When to use
Use to compute a numeric remainder while preserving decimal precision better
than direct JavaScript % for decimal operands.
Example (Calculating remainders)
import { Number } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Number.remainder(2, 2), 0)
assert.deepStrictEqual(Number.remainder(3, 2), 1)
assert.deepStrictEqual(Number.remainder(-4, 2), -0)
remainder: {
(divisor: numberdivisor: number): (self: numberself: number) => number
(self: numberself: number, divisor: numberdivisor: number): number
} = import dualdual(2, (self: numberself: number, divisor: numberdivisor: number): number => {
const const selfString: stringselfString = self: numberself.Number.toString(radix?: number): stringReturns a string representation of an object.
toString()
const const divisorString: stringdivisorString = divisor: numberdivisor.Number.toString(radix?: number): stringReturns a string representation of an object.
toString()
if (const selfString: stringselfString.String.includes(searchString: string, position?: number): booleanReturns true if searchString appears as a substring of the result of converting this
object to a String, at one or more positions that are
greater than or equal to position; otherwise, returns false.
includes("e") || const divisorString: stringdivisorString.String.includes(searchString: string, position?: number): booleanReturns true if searchString appears as a substring of the result of converting this
object to a String, at one or more positions that are
greater than or equal to position; otherwise, returns false.
includes("e")) {
if (!module globalThisglobalThis.var Number: NumberConstructorAn object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number.NumberConstructor.isFinite(number: unknown): booleanReturns true if passed value is finite.
Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
number. Only finite values of the type number, result in true.
isFinite(self: numberself) || !module globalThisglobalThis.var Number: NumberConstructorAn object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number.NumberConstructor.isFinite(number: unknown): booleanReturns true if passed value is finite.
Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
number. Only finite values of the type number, result in true.
isFinite(divisor: numberdivisor) || divisor: numberdivisor === 0) {
return var NaN: numberNaN
}
return function remainderWithScientificNotation(
self: number,
divisor: number
): number
remainderWithScientificNotation(self: numberself, divisor: numberdivisor)
}
const const selfDecCount: numberselfDecCount = (const selfString: stringselfString.String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)Split a string into substrings using the specified separator and return them as an array.
split(".")[1] || "").String.length: numberReturns the length of a String object.
length
const const divisorDecCount: numberdivisorDecCount = (const divisorString: stringdivisorString.String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)Split a string into substrings using the specified separator and return them as an array.
split(".")[1] || "").String.length: numberReturns the length of a String object.
length
const const decCount: numberdecCount = const selfDecCount: numberselfDecCount > const divisorDecCount: numberdivisorDecCount ? const selfDecCount: numberselfDecCount : const divisorDecCount: numberdivisorDecCount
const const selfInt: numberselfInt = function parseInt(
string: string,
radix?: number
): number
Converts a string to an integer.
parseInt(self: numberself.Number.toFixed(fractionDigits?: number): stringReturns a string representing a number in fixed-point notation.
toFixed(const decCount: numberdecCount).String.replace(searchValue: string | RegExp, replaceValue: string): string (+3 overloads)Replaces text in a string, using a regular expression or search string.
replace(".", ""))
const const divisorInt: numberdivisorInt = function parseInt(
string: string,
radix?: number
): number
Converts a string to an integer.
parseInt(divisor: numberdivisor.Number.toFixed(fractionDigits?: number): stringReturns a string representing a number in fixed-point notation.
toFixed(const decCount: numberdecCount).String.replace(searchValue: string | RegExp, replaceValue: string): string (+3 overloads)Replaces text in a string, using a regular expression or search string.
replace(".", ""))
return (const selfInt: numberselfInt % const divisorInt: numberdivisorInt) / var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.pow(x: number, y: number): numberReturns the value of a base expression taken to a specified power.
pow(10, const decCount: numberdecCount)
})