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

Function correctDigits

test/big-decimal/comprehensive-benchmark.ts:80–84  ·  view source on GitHub ↗

Derive the number of correct significant digits from relative error.

(relErr: number)

Source from the content-addressed store, hash-verified

78
79/** Derive the number of correct significant digits from relative error. */
80function correctDigits(relErr: number): number {
81 if (relErr === 0) return Infinity;
82 if (!isFinite(relErr)) return 0;
83 return Math.max(0, Math.floor(-Math.log10(relErr)));
84}
85
86function withPrecision<T>(prec: number, fn: () => T): T {
87 const savedBD = BigDecimal.precision;

Callers 2

identityDigitsFunction · 0.85

Calls 2

isFiniteFunction · 0.85
floorMethod · 0.45

Tested by

no test coverage detected