10000 numpy.MachAr does not allow for denormals · Issue #5755 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

numpy.MachAr does not allow for denormals #5755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OceanWolf opened this issue Apr 8, 2015 · 6 comments
Closed

numpy.MachAr does not allow for denormals #5755

OceanWolf opened this issue Apr 8, 2015 · 6 comments

Comments

@OceanWolf
Copy link

Using numpy 1.8.2 on python 2.7.9, the return value of MachAr.xmin does not take into consideration of denormals, getting a value of e-308 (see below), but much lower values exist for floats in the form of denormals.

In [1]: import numpy as np

In [2]: np.MachAr(float).xmin
Out[2]: 2.2250738585072014e-308
@juliantaylor
Copy link
Contributor

the documentation says xmin is ibeta**minexp and minexp is the smallest exponential with no leading zeros in the mantissa.
So the value is correct, though the naming is misleading

to get the real smallest value you can use np.nextafter(0, 1)

@juliantaylor
Copy link
Contributor

note though that if you're C'library is compiled with a different compiler than numpy ´np.nextafter´ might give you the wrong result. subnormal support is compiler dependent, e.g. intels compiler flushes them to zero by default

@argriffing
Copy link
Contributor

Maybe this is what is meant by 'usable' in 'the smallest [in magnitude] usable floating value'?

@ewmoore
Copy link
Contributor
ewmoore commented Apr 8, 2015

Given the large run time penalty from subnormals, I don't think we should
encourage people to introduce them deliberately into their code.

On Wed, Apr 8, 2015 at 11:26 AM, argriffing notifications@github.com
wrote:

Maybe this is what is meant by 'usable' in 'the smallest [in magnitude]
usable floating value'?


Reply to this email directly or view it on GitHub
#5755 (comment).

@OceanWolf
Copy link
Author

@ewmoore I understand your concern, but at the moment the docs appear out of sync with code, and that doesn't seem right.

I think we need to make it clear what we mean by usable and machine. Once we have clear definitions of those, we can then determine whether the doc and/or the code needs to change.

For example does the term machine refer to just the base architecture, or the software compiled for it, if I understand @juliantaylor's comment correctly, the architecture should always support subnormals, however it depends on the compiliation of the software as to whether the end user can use it or not.

@WarrenWeckesser
Copy link
Member

MachAr has been deprecated in #20201, so I don't think the MachAr code or docs will be updated. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0