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

Function atPrecision

test/big-decimal/elementary-completeness.test.ts:15–23  ·  view source on GitHub ↗

Run `fn` at a temporarily raised precision, restoring afterwards.

(p: number, fn: () => T)

Source from the content-addressed store, hash-verified

13
14/** Run `fn` at a temporarily raised precision, restoring afterwards. */
15function 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). */
26function sigDigits(x: BigDecimal, digits: number): string {

Callers 1

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected