Skip to content

gh-132908: add math.normal/subnormal() functions #132935

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

skirpichev
Copy link
Member

@skirpichev skirpichev commented Apr 25, 2025

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some cosmetic nits.

skirpichev and others added 2 commits April 25, 2025 17:45
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz
Copy link
Member

picnixz commented Apr 25, 2025

So, we have some known buildbots issues. I'll wait for it to be solved and then once it's ok for them, I'll merge it.

@skirpichev
Copy link
Member Author

Technically it's very trivial pr, yet I would appreciate a second look from someone.

Maybe we should be more vague and not define in any way normal/subnormal meaning (i.e. not reference sys.float_info). (Or mention this as CPython implementation detail.) E.g. should all Python implementations support subnormals?

Copy link
Contributor

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the docs and implementation are fine, everything is explained well.

Copy link
Member Author

@skirpichev skirpichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can replace "floating-point number" with just a "number" (as integer are automatically converted to floats)?

Comment on lines +56 to +57
:func:`isnormal(x) <isnormal>` Check if *x* is a normal floating-point number
:func:`issubnormal(x) <issubnormal>` Check if *x* is a subnormal floating-point number
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`isnormal(x) <isnormal>` Check if *x* is a normal floating-point number
:func:`issubnormal(x) <issubnormal>` Check if *x* is a subnormal floating-point number
:func:`isnormal(x) <isnormal>` Check if *x* is a normal number
:func:`issubnormal(x) <issubnormal>` Check if *x* is a subnormal number

Comment on lines +381 to +383
Return ``True`` if *x* is a normal floating-point number, that is a finite
nonzero number that is not a subnormal (see :func:`issubnormal`).
Return ``False`` otherwise.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return ``True`` if *x* is a normal floating-point number, that is a finite
nonzero number that is not a subnormal (see :func:`issubnormal`).
Return ``False`` otherwise.
Return ``True`` if *x* is a normal number, that is a finite
nonzero number that is not a subnormal (see :func:`issubnormal`).
Return ``False`` otherwise.

Comment on lines +390 to +392
Return ``True`` if *x* is a subnormal floating-point 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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return ``True`` if *x* is a subnormal floating-point 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.
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.

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

Successfully merging this pull request may close these issues.

3 participants