bpo-39310: Add math.ulp(x)#17965
Conversation
|
The documentation should be enhanced 😊 |
Done. I copied the test_math.ulp() docstring. |
|
I think Java does as well as can be done here: https://www.geeksforgeeks.org/java-math-ulp-method-examples/ Short course:
|
|
@mdickinson, @tim-one, @serhiy-storchaka: I updated the PR. Would you mind to review it again? I rewrote the documentation to clarify the behavior on corner cases: zero, min/max, inf, NaN. |
mdickinson
left a comment
There was a problem hiding this comment.
One request for an explicit test for ulp(-0.0). Apart from that, this LGTM.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Agree with @mdickinson. The rest LGTM.
|
Interesting case, |
|
I'm not sure that |
This is fine; it's just round-ties-to-even at work. |
I wrote tests differently to better highlight that we expect |
|
Oh, nntplib test fail on the Documentation job of Travis CI: I retry the job. |
Floating points are so complex :-( |
|
Oops, I forgot to update the documentation in the docstring and commit message: updated. |
Add math.ulp(): return the value of the least significant bit of a float.
|
Thanks a lot @tim-one, @serhiy-storchaka and @mdickinson: the review was required and really helpful here ;-) |
bpo-39310: Add math.ulp(x) (pythonGH-17965)
Add math.ulp(): return the value of the least significant bit of a float.
Add math.ulp(): return the unit in the last place of x.
https://bugs.python.org/issue39310