(self: BigDecimal)
| 193 | if (self.normalized === undefined) { |
| 194 | if (self.value === bigint0) { |
| 195 | self.normalized = zero |
| 196 | } else { |
| 197 | const digits = `${self.value}` |
| 198 | |
| 199 | let trail = 0 |
| 200 | for (let i = digits.length - 1; i >= 0; i--) { |
| 201 | if (digits[i] === "0") { |
| 202 | trail++ |
| 203 | } else { |
| 204 | break |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (trail === 0) { |
| 209 | self.normalized = self |
| 210 | } |
| 211 | |
| 212 | const value = BigInt(digits.substring(0, digits.length - trail)) |
| 213 | const scale = self.scale - trail |
| 214 | self.normalized = makeNormalizedUnsafe(value, scale) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | return self.normalized |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Changes a `BigDecimal` to the specified scale. |
| 223 | * |
| 224 | * **When to use** |
| 225 | * |
no test coverage detected
searching dependent graphs…