Skip to content

Change in longdouble calculations in numpy >= 1.12 on OSX #8608

@matthew-brett

Description

@matthew-brett

For numpy 1.11.3:

In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.11.3'
In [3]: np.float128(2) ** 16383
Out[3]: 5.9486574767861588254e+4931

This is correct, as 16383 is the maximum exponent value for the float-80 longdouble on OSX.

For numpy 1.12 and curent master:

In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.13.0.dev0+a9d6941'
In [3]: np.float128(2) ** 16383
/Users/mb312/.virtualenvs/test3/bin/ipython:1: RuntimeWarning: overflow encountered in longdouble_scalars
  #!/Users/mb312/.virtualenvs/test3/bin/python3.5
Out[3]: inf

In fact, numpy >= 1.12 seems to be using float64 for this calculation:

In [13]: np.float128(2) ** 1024
/Users/mb312/.virtualenvs/test3/bin/ipython:1: RuntimeWarning: overflow encountered in longdouble_scalars
  #!/Users/mb312/.virtualenvs/test3/bin/python3.5
Out[13]: inf
In [14]: np.float128(2) ** 1023
Out[14]: 8.9884656743115795386e+307

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions