Derive the number of correct significant digits from relative error.
(relErr: number)
| 78 | |
| 79 | /** Derive the number of correct significant digits from relative error. */ |
| 80 | function correctDigits(relErr: number): number { |
| 81 | if (relErr === 0) return Infinity; |
| 82 | if (!isFinite(relErr)) return 0; |
| 83 | return Math.max(0, Math.floor(-Math.log10(relErr))); |
| 84 | } |
| 85 | |
| 86 | function withPrecision<T>(prec: number, fn: () => T): T { |
| 87 | const savedBD = BigDecimal.precision; |
no test coverage detected