| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Some nitpicks, based on wording in the C17.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
IMO it's ok to cast C signint() int result into a Python boolean, since it's unlikely that the signbit() will return values others than 0 and 1 in the future. The manual page says:
RETURN VALUE
The signbit() macro returns nonzero if the sign of x is negative; other-
wise it returns zero.
Sorry, something went wrong.
Actually, signbit does return something else than 0/1 (in C) at least on some platforms, but that's what all predicate functions do in math.h (they are all specified as returning nonzero value if the condition holds). However, in C++, they return true/false. Note that https://en.cppreference.com/w/c/numeric/math/signbit shows an example where signbit() returns 128 for a negative zero. However, since we return booleans for isfinite() etc, I also returned a boolean for signbit() (and in practice, people don't care about the return value, they only care about the test) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
cc @mdickinson @skirpichev @rhettinger
I made the choice of returning True/False like numpy rather than the nonzero value itself as in C. If you want me to have another function that returns a boolean and keep signbit as in C, please tell me.
📚 Documentation preview 📚: https://cpython-previews--135877.org.readthedocs.build/