You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sagemathgh-40178: Make preparser can handle large(4301+ digits) integers
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixessagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixessagemath#12345". -->
I'm pretty sure sage wants to use all kinds of numbers without losing
precision, or errors, since I can see `sys.set_int_max_str_digits(0)` in
all.py.
However, even with the limit set to 0 (unlimited) in all.py which is
called during import, it still cannot handle 4301+ digits integers,
because Python refuses to run if there's 4301+ digit number in the first
place.
For example, the following sage code has the following error (the
11...11 is actually 5000 digits of 1):
**long.sage**
```
a = 11...11
```
```
sage long.sage
File "/home/soon_haari/mysage/long.sage.py", line 6
_sage_const_11...11
SyntaxError: Exceeds the limit (4300 digits) for integer string
conversion: value has 5000 digits; use sys.set_int_max_str_digits() to
increase the limit - Consider hexadecimal for huge integer literals to
avoid decimal conversion limits.
```
In more details, `11...11` parses to `Integer(11...11)` where 11...11 in
Integer is supposed to be `<class 'int'>` in Python.
I suggest it parses to `Integer('11...11')` instead.
Funnily enough, real/complex numbers like `1.1` or `1j` or even `1.1j`
have no problem due to long digits, because it parses to
`RealNumber('1.1')`, `ComplexNumber(0, '1')`, `ComplexNumber(0, '1.1')`
which use string as arguments already. I suggest the same fix.
This fixessagemath#40179.
### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
URL: sagemath#40178
Reported by: Minsun Kim
Reviewer(s): Minsun Kim, Travis Scrimshaw, user202729, Vincent Macri
0 commit comments