* Extract the significant digit string from a numeric string. * Strips sign, decimal point, leading zeros. Preserves trailing zeros.
(s: string)
| 19 | * Strips sign, decimal point, leading zeros. Preserves trailing zeros. |
| 20 | */ |
| 21 | function 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. |
no test coverage detected