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

Function sigDigits

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

* Extract the significant digit string from a numeric string. * Strips sign, decimal point, leading zeros. Preserves trailing zeros.

(s: string)

Source from the content-addressed store, hash-verified

19 * Strips sign, decimal point, leading zeros. Preserves trailing zeros.
20 */
21function sigDigits(s: string): string {
22 if (s.startsWith('-') || s.startsWith('+')) s = s.slice(1);
23 const eIdx = s.search(/[eE]/);
24 if (eIdx !== -1) s = s.slice(0, eIdx);
25 s = s.replace('.', '');
26 s = s.replace(/^0+/, '');
27 return s;
28}
29
30/**
31 * Count matching significant digits between two numeric strings.

Callers 1

matchingDigitsFunction · 0.70

Calls 2

sliceMethod · 0.65
replaceMethod · 0.65

Tested by

no test coverage detected