-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-135308: clarify math.issubnormal() description #135324
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
base: main
Are you sure you want to change the base?
Conversation
Small related problem. If you follow to sys.float_info.min - you find yourself in the middle of the |
@@ -387,8 +387,8 @@ Floating point manipulation functions | |||
.. function:: issubnormal(x) | |||
|
|||
Return ``True`` if *x* is a subnormal number, that is a finite | |||
nonzero number with a magnitude smaller than the smallest positive normal | |||
number, see :data:`sys.float_info.min`. Return ``False`` otherwise. | |||
nonzero number with a magnitude smaller than :data:`sys.float_info.min`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magnitude is an integer, it'll be smaller than sys.float_info.min
if x is smaller than 1
.
nonzero number with a magnitude smaller than :data:`sys.float_info.min`. | |
nonzero number smaller than :data:`sys.float_info.min`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the original meant “smaller than the magnitude of the smallest positive normal number”, but that's just extra words.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be incorrect, as any finite negative floating-point number will satisfy your definition.
The magnitude is an integer
No. It's about absolute value of the float. See e.g. copysign() docs.
math.isnormal
andmath.issubnormal
referring to "normality" without context #135308📚 Documentation preview 📚: https://cpython-previews--135324.org.readthedocs.build/
https://cpython-previews--135324.org.readthedocs.build/en/135324/library/math.html#math.issubnormal