Commit edb1ce9
Release Manager
gh-40279: Fix RealLiteral to float conversion
Previously we see the following behavior
sage: float(1.133759543500045e+153)
1.1337595435000451e+153
sage: float('1.133759543500045e+153')
1.133759543500045e+153
This is because `RealLiteral` constructor determine `prec=54`, so the
string `1.133759543500045e+153` is first converted to 54 bits, then
rounded to 53 bits. This introduces the error because of [double
rounding](https://en.wikipedia.org/wiki/Rounding#Double_rounding).
Also fix the issue where `n(RealNumber('12', base=16))` returns 12. (now
it correctly returns 18.)
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #40279
Reported by: user202729
Reviewer(s): Martin Rubey, user202729
1 file changed
+31
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5694 | 5694 | | |
5695 | 5695 | | |
5696 | 5696 | | |
5697 | | - | |
| 5697 | + | |
5698 | 5698 | | |
5699 | 5699 | | |
5700 | | - | |
| 5700 | + | |
5701 | 5701 | | |
5702 | 5702 | | |
5703 | 5703 | | |
| 5704 | + | |
| 5705 | + | |
5704 | 5706 | | |
5705 | 5707 | | |
5706 | 5708 | | |
5707 | 5709 | | |
5708 | | - | |
| 5710 | + | |
5709 | 5711 | | |
5710 | 5712 | | |
5711 | 5713 | | |
5712 | 5714 | | |
5713 | 5715 | | |
5714 | 5716 | | |
5715 | 5717 | | |
5716 | | - | |
5717 | | - | |
5718 | | - | |
| 5718 | + | |
| 5719 | + | |
5719 | 5720 | | |
5720 | 5721 | | |
5721 | 5722 | | |
| |||
5728 | 5729 | | |
5729 | 5730 | | |
5730 | 5731 | | |
5731 | | - | |
| 5732 | + | |
5732 | 5733 | | |
5733 | | - | |
5734 | | - | |
| 5734 | + | |
| 5735 | + | |
| 5736 | + | |
| 5737 | + | |
| 5738 | + | |
| 5739 | + | |
| 5740 | + | |
| 5741 | + | |
| 5742 | + | |
| 5743 | + | |
| 5744 | + | |
| 5745 | + | |
| 5746 | + | |
| 5747 | + | |
| 5748 | + | |
| 5749 | + | |
| 5750 | + | |
5735 | 5751 | | |
5736 | 5752 | | |
5737 | 5753 | | |
| |||
5774 | 5790 | | |
5775 | 5791 | | |
5776 | 5792 | | |
| 5793 | + | |
| 5794 | + | |
| 5795 | + | |
| 5796 | + | |
| 5797 | + | |
5777 | 5798 | | |
5778 | 5799 | | |
5779 | 5800 | | |
5780 | | - | |
| 5801 | + | |
5781 | 5802 | | |
5782 | 5803 | | |
5783 | 5804 | | |
| |||
0 commit comments