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

Function matchingDigits

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

* Count matching significant digits between two numeric strings. * Returns the number of leading digits that agree.

(a: string, b: string)

Source from the content-addressed store, hash-verified

32 * Returns the number of leading digits that agree.
33 */
34function matchingDigits(a: string, b: string): number {
35 const da = sigDigits(a);
36 const db = sigDigits(b);
37 const len = Math.min(da.length, db.length);
38 for (let i = 0; i < len; i++) {
39 if (da[i] !== db[i]) return i;
40 }
41 return len;
42}
43
44/**
45 * Compute factorial as a BigDecimal string.

Callers 3

precisionReportFunction · 0.85
gammaReportFunction · 0.85

Calls 1

sigDigitsFunction · 0.70

Tested by

no test coverage detected