effect-io-ai

Package: effect
Module: BigInt

BigInt.sqrt

Determines the square root of a given bigint safely. Returns none if the given bigint is negative.

Example

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

assert.deepStrictEqual(BigInt.sqrt(4n), Option.some(2n))
assert.deepStrictEqual(BigInt.sqrt(9n), Option.some(3n))
assert.deepStrictEqual(BigInt.sqrt(16n), Option.some(4n))
assert.deepStrictEqual(BigInt.sqrt(-1n), Option.none())

Signature

declare const sqrt: (n: bigint) => Option.Option<bigint>

Source

Since v2.0.0