(s: string)
| 60 | } |
| 61 | |
| 62 | function parseDecimalString(s: string): { |
| 63 | mantissa: bigint |
| 64 | exponent: number |
| 65 | special: SpecialValue |
| 66 | negativeZero: boolean |
| 67 | } { |
| 68 | s = s.trim() |
| 69 | |
| 70 | if (s === 'NaN') { |
| 71 | return { |
| 72 | mantissa: 0n, |
| 73 | exponent: 0, |
| 74 | special: SpecialValue.NAN, |
| 75 | negativeZero: false, |
| 76 | } |
| 77 | } |
| 78 | if (s === 'Infinity' || s === '+Infinity') { |
| 79 | return { |
| 80 | mantissa: 0n, |
| 81 | exponent: 0, |
| 82 | special: SpecialValue.POSITIVE_INFINITY, |
| 83 | negativeZero: false, |
| 84 | } |
| 85 | } |
| 86 | if (s === '-Infinity') { |
| 87 | return { |
| 88 | mantissa: 0n, |
| 89 | exponent: 0, |
| 90 | special: SpecialValue.NEGATIVE_INFINITY, |
| 91 | negativeZero: false, |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | let negative = false |
| 96 | let idx = 0 |
| 97 | if (s[idx] === '-') { |
| 98 | negative = true |
| 99 | idx++ |
| 100 | } else if (s[idx] === '+') { |
| 101 | idx++ |
| 102 | } |
| 103 | |
| 104 | // Split by 'e' or 'E' for scientific notation |
| 105 | let eIdx = s.indexOf('e', idx) |
| 106 | if (eIdx === -1) eIdx = s.indexOf('E', idx) |
| 107 | let sciExp = 0 |
| 108 | let numPart: string |
| 109 | if (eIdx !== -1) { |
| 110 | sciExp = parseInt(s.substring(eIdx + 1), 10) |
| 111 | numPart = s.substring(idx, eIdx) |
| 112 | } else { |
| 113 | numPart = s.substring(idx) |
| 114 | } |
| 115 | |
| 116 | // Split by decimal point |
| 117 | const dotIdx = numPart.indexOf('.') |
| 118 | let intPart: string |
| 119 | let fracPart: string |
no test coverage detected