Package: effect
Module: BigDecimal
Returns the decimal remainder left over when one operand is divided by a non-zero second operand.
When to use
Use when you need to compute a BigDecimal remainder with a divisor known to
be non-zero and want a plain BigDecimal result instead of an Option.
Gotchas
Throws a RangeError if the divisor is 0.
Example (Computing remainders unsafely)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(
BigDecimal.remainderUnsafe(BigDecimal.fromStringUnsafe("2"), BigDecimal.fromStringUnsafe("2")),
BigDecimal.fromStringUnsafe("0")
)
assert.deepStrictEqual(
BigDecimal.remainderUnsafe(BigDecimal.fromStringUnsafe("3"), BigDecimal.fromStringUnsafe("2")),
BigDecimal.fromStringUnsafe("1")
)
assert.deepStrictEqual(
BigDecimal.remainderUnsafe(BigDecimal.fromStringUnsafe("-4"), BigDecimal.fromStringUnsafe("2")),
BigDecimal.fromStringUnsafe("0")
)
See
remainder for returning Option.none when the divisor is zeroSignature
declare const remainderUnsafe: { (divisor: BigDecimal): (self: BigDecimal) => BigDecimal; (self: BigDecimal, divisor: BigDecimal): BigDecimal; }
Since v4.0.0