[Numpy-discussion] np.finfo().maxexp confusing

Matthew Brett matthew.brett@gmail....
Tue Oct 11 15:55:50 CDT 2011


On Tue, Oct 11, 2011 at 2:39 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
> Hi,
> I realize it is probably too late to do anything about this, but:
> In [72]: info = np.finfo(np.float32)
> In [73]: info.minexp
> Out[73]: -126
> In [74]: info.maxexp
> Out[74]: 128
> minexp is correct, in that 2**(-126) is the minimum value for the
> exponent part of float32.  But maxexp is not correct, because 2**(127)
> is the maximum value for the float32 exponent part:
> http://en.wikipedia.org/wiki/Single_precision_floating-point_format
> There is the same maxexp+1 feature for the other float types.
> Is this a sufficiently quiet corner of the API that it might be
> changed in the future with suitable warnings?

Ah - I just found this:


which explains that:

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

which is - unpleasantly named, but at least, clearly documented - if
not at the point of use.  When I've got better internet access, I'll
try and modify the finfo docstring to explain.

See you,


More information about the NumPy-Discussion mailing list