New submission from Fredrik Johansson <[EMAIL PROTECTED]>:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import ldexp
>>> from sys import maxint

>>> ldexp(1.234, maxint//2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: math range error

>>> ldexp(1.234, maxint)
0.0

>>> ldexp(1.234, -maxint)
0.0

>>> ldexp(1.234, -maxint-2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to int

The first and third cases seem right.

The second is clearly a bug.

In the fourth case, it would be more correct to return 0.0 than to raise
an exception IMHO.

----------
components: Library (Lib)
messages: 64527
nosy: fredrikj
severity: normal
status: open
title: ldexp(x,n) misbehaves when abs(n) is large
type: behavior
versions: Python 2.5

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2487>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to