(n: bigint): bigintDetermines 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 const abs: (n: bigint) => bigintDetermines 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)
abs = (n: bigintn: bigint): bigint => (n: bigintn < const bigint0: bigintbigint0 ? -n: bigintn : n: bigintn)