()
| 640 | } |
| 641 | |
| 642 | toString(): string { |
| 643 | if (this._special === SpecialValue.NAN) return 'NaN' |
| 644 | if (this._special === SpecialValue.POSITIVE_INFINITY) return 'Infinity' |
| 645 | if (this._special === SpecialValue.NEGATIVE_INFINITY) return '-Infinity' |
| 646 | if (this._mantissa === 0n) return '0' |
| 647 | |
| 648 | const negative = this._mantissa < 0n |
| 649 | const absStr = bigintAbs(this._mantissa).toString() |
| 650 | const prefix = negative ? '-' : '' |
| 651 | |
| 652 | if (this._exponent === 0) { |
| 653 | return prefix + absStr |
| 654 | } |
| 655 | |
| 656 | if (this._exponent > 0) { |
| 657 | // Append zeros |
| 658 | return prefix + absStr + '0'.repeat(this._exponent) |
| 659 | } |
| 660 | |
| 661 | // Negative exponent: insert decimal point |
| 662 | const decimalPlaces = -this._exponent |
| 663 | if (decimalPlaces < absStr.length) { |
| 664 | const intPart = absStr.slice(0, absStr.length - decimalPlaces) |
| 665 | const fracPart = absStr.slice(absStr.length - decimalPlaces) |
| 666 | return prefix + intPart + '.' + fracPart |
| 667 | } else { |
| 668 | // Need leading zeros: 0.000...digits |
| 669 | const leadingZeros = decimalPlaces - absStr.length |
| 670 | return prefix + '0.' + '0'.repeat(leadingZeros) + absStr |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | // --- Static --- |
| 675 |
no test coverage detected