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

Function withPrecision

test/big-decimal/cross-validation.test.ts:96–107  ·  view source on GitHub ↗

* Save and restore precision for both libraries.

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

Source from the content-addressed store, hash-verified

94 * Save and restore precision for both libraries.
95 */
96function withPrecision<T>(prec: number, fn: () => T): T {
97 const savedBD = BigDecimal.precision;
98 const savedDJ = Decimal.precision;
99 try {
100 BigDecimal.precision = prec;
101 Decimal.set({ precision: prec });
102 return fn();
103 } finally {
104 BigDecimal.precision = savedBD;
105 Decimal.set({ precision: savedDJ });
106 }
107}
108
109// ================================================================
110// Division

Callers 1

Calls 2

fnFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected