(bits: number)
| 653 | } |
| 654 | |
| 655 | function 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) |
no test coverage detected