[Python-bugs-list] [ python-Bugs-525705 ] underflow raise OverflowException

noreply@sourceforge.net noreply@sourceforge.net
Mon, 04 Mar 2002 16:48:56 -0800


Bugs item #525705, was opened at 2002-03-04 18:56
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=525705&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
>Priority: 7
Submitted By: Huaiyu Zhu (hzhu)
Assigned to: Nobody/Anonymous (nobody)
Summary: underflow raise OverflowException

Initial Comment:
Python 2.2 (#1, Mar  4 2002, 15:25:20) 
[GCC 2.95.2 19991024 (release)] on linux2
>>> 1e-200**2
OverflowError: (34, 'Numerical result out of range')

The machine runs SuSE 7.1. $ rpm -q gcc glibc
gcc-2.95.2-149
glibc-2.2-7

On this machine, the following test C program produces
1e+200   inf 34 Numerical result out of range 34
1e-200     0 34 Numerical result out of range 34
without -lieee, and 

1e+200   inf 0 Success 34
1e-200     0 0 Success 34
with -lieee.

However, editing pyconfig.h.in to add line
#define HAVE_LIBIEEE 1
does not change Python's behavior.

This problem does not occur on another machine, running
Red Hat 6.1 upgraded to 7.1.  It exhibits exactly the
same behavior regarding C, but Python underflows to 0.0
properly. 


The test C program is

#include <math.h>
#include <stdlib.h>
#include <errno.h>
extern int errno;

main() {
  double x;
  x = 1e200;
  printf("%g %5g %d %s %d\n", x, pow(x, 2), errno,
strerror(errno), ERANGE);
  x = 1e-200;
  printf("%g %5g %d %s %d\n", x, pow(x, 2), errno,
strerror(errno), ERANGE);
}


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-03-04 19:48

Message:
Logged In: YES 
user_id=31435

Boosted priority.  I'd assign to me, except I don't know 
anything about Linux config.

Paul Rubin reported success (no more bogus OverflowError) 
after

"""
I manually put "-lieee" into the LIBS=... line in the 
makefile and rebuilt.
"""

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=525705&group_id=5470