-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
nextfloat behaviour near Inf #16206
Comments
This is clearly an error. Even more worrying is:
|
The manual states that nextfloat and prevfloat use lexicographic order, but to me this meant that NaN's would either be ordered by their bits, or not ordered at all. The previous routine appears to give you the next 'higher' NaN in the sense of bits. The proposed routine instead follows the second branch of the final conditional and returns a signed infinity:
Proposed behavior:
|
Apologies -- Contrary to what I said, Simonbyrne's actual commit (rather than the proposed code above) treats all NaNs the same. |
Seems like the manual isn't quite right, since
I'm not really sure which part of 6.2 they're referring to, but there is there is this sentence:
which would seem to indicate that for NaNs we should return the same payload. |
That makes sense. Thanks for fixing this. FYI: I found that when I static typed the arguments, the new routine introduces about six additional branches, which we might want to worry about. However, nonetheless, it is slightly more performant than the previous version. |
Thanks, that's good to know. Some of the additional branches are to
correctly handle things like BigInts, but I intentionally wrote the code so
that the JIT should be able to remove them in other cases. Please do let me
know if you have other suggestions.
|
By the way, the two-argument form of |
I find this behaviour surprising:
I would expect the last call to return
Inf
as well.The following code seems to do what I expected:
The text was updated successfully, but these errors were encountered: