(y: BigDecimal | number | string | bigint)
| 246 | } |
| 247 | |
| 248 | div(y: BigDecimal | number | string | bigint): BigDecimal { |
| 249 | const other = BigDecimal._coerce(y) |
| 250 | if (this._special || other._special) { |
| 251 | return this._specialArith(other, 'div') |
| 252 | } |
| 253 | if (other._mantissa === 0n) { |
| 254 | if (this._mantissa === 0n) { |
| 255 | return BigDecimal._create(0n, 0, SpecialValue.NAN, false) |
| 256 | } |
| 257 | const neg = this._isSignNegative() !== other._isSignNegative() |
| 258 | return BigDecimal._create( |
| 259 | 0n, |
| 260 | 0, |
| 261 | neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, |
| 262 | false |
| 263 | ) |
| 264 | } |
| 265 | if (this._mantissa === 0n) { |
| 266 | const negZero = this._isSignNegative() !== other._isSignNegative() |
| 267 | return BigDecimal._create(0n, 0, SpecialValue.NONE, negZero) |
| 268 | } |
| 269 | // Scale numerator for precision |
| 270 | const scaledNumerator = this._mantissa * bigintPow10(DIV_PRECISION) |
| 271 | const quotient = scaledNumerator / other._mantissa |
| 272 | const newExponent = this._exponent - other._exponent - DIV_PRECISION |
| 273 | const [nm, ne] = removeTrailingZeros(quotient, newExponent) |
| 274 | return BigDecimal._create(nm, ne, SpecialValue.NONE, false) |
| 275 | } |
| 276 | |
| 277 | plus(y: BigDecimal | number | string | bigint): BigDecimal { |
| 278 | const other = BigDecimal._coerce(y) |
no test coverage detected