[Numpy-discussion] Incorrect overflow warning message for float128

Edward C. Jones edcjones at comcast.net
Sat Jun 9 22:58:29 EDT 2012


I use up-to-date Debian testing (wheezy), amd64 architecture.

 From the docs for numpy.MachAr:

maxexp int Smallest (positive) power of ibeta that causes overflow.

On my machine, ibeta = 2 and maxexp = 16384.

For float64, float32, and float16 things behave as expected.  For float128,
I get the message about overflow for exponent 8192 (and greater) but the
correct answer is printed.  What is the problem?

#! /usr/bin/env python3.2

import numpy

print('float128')
fi = numpy.finfo(numpy.float128)
print('ibeta:', fi.machar.ibeta)  # 2
print('maxexp:', fi.machar.maxexp)  # 16384
print('xmax:', fi.machar.xmax)  # 1.18973149536e+4932
two = numpy.float128(2)
big = numpy.float128(8191)
x = numpy.power(two, big)
print('2**8191:', x)  # 5.4537406781e+2465
big = numpy.float128(8192)
# RuntimeWarning: overflow encountered in power
x = numpy.power(two, big)
print('2**8192:', x)  # 1.09074813562e+2466




More information about the NumPy-Discussion mailing list