Hyperlinkv0.8.0-beta.28

BigInt

BigInt.divideUnsafeconsteffect/BigInt.ts:226
(that: bigint): (self: bigint) => bigint
(self: bigint, that: bigint): bigint

Divides one bigint by another, throwing if the divisor is zero.

When to use

Use to divide bigint values where the divisor is known to be non-zero and division by zero should be a thrown exception.

Details

Uses JavaScript bigint division, so non-exact quotients are truncated toward zero.

Gotchas

Throws a RangeError when the divisor is 0n.

Example (Dividing bigints unsafely)

import { BigInt } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(BigInt.divideUnsafe(6n, 3n), 2n)
assert.deepStrictEqual(BigInt.divideUnsafe(6n, 4n), 1n)
mathdivide
Source effect/BigInt.ts:2264 lines
export const divideUnsafe: {
  (that: bigint): (self: bigint) => bigint
  (self: bigint, that: bigint): bigint
} = dual(2, (self: bigint, that: bigint): bigint => self / that)