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

Function withPrecision

test/big-decimal/comprehensive-benchmark.ts:86–97  ·  view source on GitHub ↗
(prec: number, fn: () => T)

Source from the content-addressed store, hash-verified

84}
85
86function withPrecision<T>(prec: number, fn: () => T): T {
87 const savedBD = BigDecimal.precision;
88 const savedDJ = Decimal.precision;
89 try {
90 BigDecimal.precision = prec;
91 Decimal.set({ precision: prec });
92 return fn();
93 } finally {
94 BigDecimal.precision = savedBD;
95 Decimal.set({ precision: savedDJ });
96 }
97}
98
99// ================================================================
100// Formatting

Callers 1

Calls 2

fnFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected