Hyperlinkv0.8.0-beta.28

BigInt

BigInt.absconsteffect/BigInt.ts:600
(n: bigint): bigint

Determines the absolute value of a given bigint.

When to use

Use to remove the sign from a bigint while preserving its magnitude.

Example (Calculating absolute values)

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

assert.deepStrictEqual(BigInt.abs(-5n), 5n)
assert.deepStrictEqual(BigInt.abs(0n), 0n)
assert.deepStrictEqual(BigInt.abs(5n), 5n)
math
Source effect/BigInt.ts:6001 lines
export const abs = (n: bigint): bigint => (n < bigint0 ? -n : n)