()
| 406 | } |
| 407 | |
| 408 | floor(): BigDecimal { |
| 409 | if (this._special !== SpecialValue.NONE) return this |
| 410 | if (this._mantissa === 0n) return this |
| 411 | if (this._exponent >= 0) return this // already an integer |
| 412 | |
| 413 | const divisor = bigintPow10(-this._exponent) |
| 414 | const m = this._mantissa |
| 415 | let q = m / divisor |
| 416 | |
| 417 | // Floor: round toward -infinity |
| 418 | // For negative numbers with remainder, subtract 1 |
| 419 | if (m < 0n && m % divisor !== 0n) { |
| 420 | q -= 1n |
| 421 | } |
| 422 | |
| 423 | if (q === 0n) { |
| 424 | // Check if we should return -0 |
| 425 | const negZero = this._mantissa < 0n |
| 426 | return BigDecimal._create(0n, 0, SpecialValue.NONE, negZero) |
| 427 | } |
| 428 | const [nm, ne] = removeTrailingZeros(q, 0) |
| 429 | return BigDecimal._create(nm, ne, SpecialValue.NONE, false) |
| 430 | } |
| 431 | |
| 432 | ceil(): BigDecimal { |
| 433 | if (this._special !== SpecialValue.NONE) return this |
no test coverage detected