Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51338
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Marco <m.b@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Division and multiplication have a different behavior in the overflow case |
| Date | Sat, 27 Jul 2013 19:48:34 +0200 |
| Organization | Aioe.org NNTP Server |
| Lines | 29 |
| Message-ID | <kt115f$8ec$1@speranza.aioe.org> (permalink) |
| NNTP-Posting-Host | 75s6hM522EBdrzJlnkQW3w.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com comp.lang.python:51338 |
Show key headers only | View raw
In Python 3, when we hava a division and both the result and at least
one operand are too large to convert to float, we get an exception:
>>> 2**1028 / 2**-2
Traceback (most recent call last):
File "<input>", line 1, in <module>
OverflowError: long int too large to convert to float
When the result is inside the limits, we get the right value:
>>> 2 ** 1025 / 2**10
3.511119404027961e+305
Why the behavior is different in the case of the multiplication?
>>> 2 ** 1025 * 2**-10
Traceback (most recent call last):
File "<input>", line 1, in <module>
OverflowError: long int too large to convert to float
I think the multiplication should have the same behavior than the
division:
* `inf` or `-inf` when the operands are inside the limits,
but the result is not
* `OverflowError` when the result, and at least one operand,
are out of range.
--
Marco Buttu
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Division and multiplication have a different behavior in the overflow case Marco <m.b@gmail.com> - 2013-07-27 19:48 +0200 Re: Division and multiplication have a different behavior in the overflow case Terry Reedy <tjreedy@udel.edu> - 2013-07-27 16:56 -0400
csiph-web