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

Function computeFppi

src/big-decimal/utils.ts:655–666  ·  view source on GitHub ↗
(bits: number)

Source from the content-addressed store, hash-verified

653}
654
655function computeFppi(bits: number): bigint {
656 // We need ~bits·log10(2) decimal digits of PI, plus guard digits.
657 const neededDigits = Math.ceil(bits * LOG10_2) + 12;
658 if (neededDigits + 1 <= PI_DIGITS.length) {
659 // Table path: PI ≈ piInt · 10^(-fracDigits), result = (piInt << bits)/10^frac
660 const digits = PI_DIGITS.slice(0, neededDigits + 1); // +1 for the "3"
661 const piInt = BigInt(digits);
662 return (piInt << BigInt(bits)) / pow10(digits.length - 1);
663 }
664 // Beyond the table: compute on demand.
665 return piChudnovskyBits(bits);
666}
667
668// ================================================================
669// Fixed-point sincos (simultaneous sin and cos)

Callers 1

fppiFunction · 0.85

Calls 4

pow10Function · 0.85
piChudnovskyBitsFunction · 0.85
sliceMethod · 0.65
ceilMethod · 0.45

Tested by

no test coverage detected