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

Function compareDigits

test/big-decimal/cross-validation.test.ts:44–56  ·  view source on GitHub ↗

* Compare the first `matchDigits` significant digits of two numeric strings. * Returns true if they match.

(
  ours: string,
  theirs: string,
  matchDigits: number
)

Source from the content-addressed store, hash-verified

42 * Returns true if they match.
43 */
44function compareDigits(
45 ours: string,
46 theirs: string,
47 matchDigits: number
48): boolean {
49 const ourDigits = significantDigits(ours);
50 const theirDigits = significantDigits(theirs);
51
52 const ourSlice = ourDigits.slice(0, matchDigits);
53 const theirSlice = theirDigits.slice(0, matchDigits);
54
55 return ourSlice === theirSlice;
56}
57
58/**
59 * Format a comparison failure message showing where the digits diverge.

Callers 1

Calls 2

significantDigitsFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected