(x: string, y: string)
| 190 | |
| 191 | // x and y decimal, lowest significant digit first |
| 192 | function addBigInt(x: string, y: string): string { |
| 193 | let sum = ''; |
| 194 | const len = Math.max(x.length, y.length); |
| 195 | for (let i = 0, carry = 0; i < len || carry; i++) { |
| 196 | const tmpSum = carry + +(x[i] || 0) + +(y[i] || 0); |
| 197 | if (tmpSum >= 10) { |
| 198 | carry = 1; |
| 199 | sum += tmpSum - 10; |
| 200 | } else { |
| 201 | carry = 0; |
| 202 | sum += tmpSum; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | return sum; |
| 207 | } |
| 208 | |
| 209 | function numberTimesBigInt(num: number, b: string): string { |
| 210 | let product = ''; |
no test coverage detected
searching dependent graphs…