On Sat, Feb 19, 2022 at 6:31 AM Damian Shaw <damian.peter.s...@gmail.com>
wrote:

> That sounds like a lot of extra checks to put on "/"
>

This isn’t about the division — it’s about the literal. The “e” notation
makes a float. And floats have fixed precision.

Python could try to be smart and create an integer for e notation that
happens to be an integer value, but I really don’t see the utility in that.

The other “Solution” would be for Python to adopt unlimited precision
floats. A major change.

-CHB


when the error message is clear and the user could implement their own
> checks if they are running into this niche use case and do 10**400 /
> int(1e200).
>
> Damian (he/him)
>
> On Sat, Feb 19, 2022 at 8:36 AM Stefan Pochmann <smpochm...@gmail.com>
> wrote:
>
>> It crashes because it tries to convert 10**400 to a float and that fails:
>>
>> >>> 10**400 / 1e200
>> Traceback (most recent call last):
>>   File "<pyshell#10>", line 1, in <module>
>>     10**400 / 1e200
>> OverflowError: int too large to convert to float
>>
>> But with two ints it succeeds:
>>
>> >>> 10**400 / 10**200
>> 1e+200
>>
>> Note that 1e200 is an integer:
>>
>> >>> 1e200.is_integer()
>> True
>>
>> So that could losslessly be converted to int, and then the division would
>> succeed:
>>
>> >>> 10**400 / int(1e200)
>> 1e+200
>>
>> So could/should 10**400 / 1e200 be implemented to do that instead of
>> raising the error? Or is it a too rare use case and not worth the effort,
>> or does something else speak against it?
>> _______________________________________________
>> Python-ideas mailing list -- python-ideas@python.org
>> To unsubscribe send an email to python-ideas-le...@python.org
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/python-ideas@python.org/message/O7FE5AAWPA77QRQPKJVT6AB3XK7QPUZG/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/LBNH5IOG2LI6TU5IVCFI76GPPOLV4ZZF/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ODU43U3C3DTJPW36RZ3FHXCSEQGDGCBW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to