thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

Incorrect overflow warning message for float128 (Trac #2164) #5956

Open numpy-gitbot opened 11 years ago

numpy-gitbot commented 11 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2164 on 2012-06-15 by trac user edcjones, assigned to unknown.

I use up-to-date Debian testing (wheezy), amd64 architecture. I have installed packages python3, version 3.23~rc1-2, and python3-numpy, version 1:1.6.2-1.

For float128, I get an overflow warning message, when I calculate 2**8192. The maximum exponent should be 16384.

Program:

! /usr/bin/env python3.2

import numpy

print('float128') fi = numpy.finfo(numpy.float128) print('ibeta:', fi.machar.ibeta) print('maxexp:', fi.machar.maxexp) print('xmax:', fi.machar.xmax) two = numpy.float128(2) big = numpy.float128(8191) x = numpy.power(two, big) # OK print('2**8191:', x) big = numpy.float128(8192) x = numpy.power(two, big)

Output:

float128 ibeta: 2 maxexp: 16384 xmax: 1.18973149536e+4932 2**8191: 5.4537406781e+2465 ./z97.py:16: RuntimeWarning: overflow encountered in power x = numpy.power(two, big)

numpy-gitbot commented 11 years ago

Attachment added by trac user edcjones on 2012-06-15: z97.py