MCPcopy Create free account
hub / github.com/Effect-TS/effect / exactRoot

Function exactRoot

packages/effect/src/Rational.ts:656–657  ·  view source on GitHub ↗
(n: bigint, degree: number)

Source from the content-addressed store, hash-verified

654
655// A root of magnitude at most one is exact only when it equals `n`, which avoids raising it to a huge degree.
656const exactRoot = (n: bigint, degree: number): Option.Option<bigint> =>
657 Option.filter(BI.nthRoot(n, degree), (r) => (BI.abs(r) <= bigint1 ? r : r ** BigInt(degree)) === n)
658
659/**
660 * Takes the exact n-th root of a rational, returning `Option.none()` when the

Callers 1

Rational.tsFile · 0.85

Calls 2

BigIntInterface · 0.70
filterMethod · 0.45

Tested by

no test coverage detected