Run `fn` at a temporarily raised precision, restoring afterwards.
(p: number, fn: () => T)
| 13 | |
| 14 | /** Run `fn` at a temporarily raised precision, restoring afterwards. */ |
| 15 | function atPrecision<T>(p: number, fn: () => T): T { |
| 16 | const saved = BigDecimal.precision; |
| 17 | BigDecimal.precision = p; |
| 18 | try { |
| 19 | return fn(); |
| 20 | } finally { |
| 21 | BigDecimal.precision = saved; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | /** First `digits` significant digits of |x| as a string (no sign, no point). */ |
| 26 | function sigDigits(x: BigDecimal, digits: number): string { |
no test coverage detected