Package: effect
Module: BigInt
Divides one bigint by another safely.
When to use
Use to divide bigint values while representing division by zero as
Option.none.
Details
Uses JavaScript bigint division, so non-exact quotients are truncated
toward zero. Returns Option.none() when the divisor is 0n.
Example (Dividing bigints safely)
import { BigInt, Option } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigInt.divide(6n, 3n), Option.some(2n))
assert.deepStrictEqual(BigInt.divide(6n, 0n), Option.none())
See
divideUnsafe for division that throws when the divisor is 0nremainder for the JavaScript remainder operationSignature
declare const divide: { (that: bigint): (self: bigint) => Option.Option<bigint>; (self: bigint, that: bigint): Option.Option<bigint>; }
Since v2.0.0