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

Function withPrecision

test/big-decimal/precision-comparison.test.ts:53–64  ·  view source on GitHub ↗
(prec: number, fn: () => T)

Source from the content-addressed store, hash-verified

51}
52
53function withPrecision<T>(prec: number, fn: () => T): T {
54 const savedBD = BigDecimal.precision;
55 const savedDJ = Decimal.precision;
56 try {
57 BigDecimal.precision = prec;
58 Decimal.set({ precision: prec });
59 return fn();
60 } finally {
61 BigDecimal.precision = savedBD;
62 Decimal.set({ precision: savedDJ });
63 }
64}
65
66/**
67 * Run a precision comparison and return a summary string for snapshot testing.

Callers 1

Calls 2

fnFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected