MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / ln2BS

Function ln2BS

src/big-decimal/utils.ts:594–604  ·  view source on GitHub ↗
(a: number, b: number)

Source from the content-addressed store, hash-verified

592 return [Pam * Pmb, Qam * Qmb, Qmb * Tam + Pam * Tmb];
593}
594
595/** Number of terms to reach `bits` of precision (with a small guard). */
596function chudTerms(bits: number): number {
597 return Math.max(2, Math.floor(bits / CHUD_BITS_PER_TERM) + 3);
598}
599
600/** π · 2^bits via Chudnovsky (no table-size ceiling). */
601export function piChudnovskyBits(bits: number): bigint {
602 const [, Q, T] = chudBS(0, chudTerms(bits));
603 // 12/C^(3/2) = 1/(426880·√10005); one = 2^bits; sqrtC = isqrt(10005·one²).
604 const one = 1n << BigInt(bits);
605 const sqrtC = bigintSqrt(10005n * one * one);
606 return (Q * 426880n * sqrtC) / T;
607}

Callers 1

ln2ChudnovskyBitsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected