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

Function precisionReport

test/big-decimal/precision-comparison.test.ts:72–86  ·  view source on GitHub ↗

* Run a precision comparison and return a summary string for snapshot testing. * * `ourFn` computes the BigDecimal result at the given precision. * `refFn` computes the reference result (decimal.js or exact) at the given precision.

(
  label: string,
  precisions: number[],
  ourFn: (prec: number) => string,
  refFn: (prec: number) => string
)

Source from the content-addressed store, hash-verified

70 * `refFn` computes the reference result (decimal.js or exact) at the given precision.
71 */
72function precisionReport(
73 label: string,
74 precisions: number[],
75 ourFn: (prec: number) => string,
76 refFn: (prec: number) => string
77): string {
78 const lines: string[] = [label];
79 for (const prec of precisions) {
80 const ours = ourFn(prec);
81 const ref = refFn(prec);
82 const digits = matchingDigits(ours, ref);
83 lines.push(` prec=${prec}: ${digits} matching digits (of ${prec})`);
84 }
85 return lines.join('\n');
86}
87
88// ---------- Tests ----------
89

Callers 1

Calls 1

matchingDigitsFunction · 0.85

Tested by

no test coverage detected