-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
math: document that Min()/Max() don't agree with builtin min()/max() #60616
Comments
This was explicitly addressed in the min/max proposal: #59488 (comment) |
Ah, good point. Well given that comment and #59488 (comment) I think we should still fix math.Min/Max. |
Unfortunately I don't think we can change |
I'm going to close, at minimum this would need to be a proposal and though I am sympathetic, I can imagine someone writing code that depends on the current behavior. It would be an interesting experiment to instrument math.Min/Max and see how often the problematic case occurred, if at all. |
Change https://go.dev/cl/501355 mentions this issue: |
Retitling this to be about documenting this difference, which CL 501355 will resolve. |
What version of Go are you using (
go version
)?What did you do?
https://go.dev/play/p/Sf_G8Lt9dHy?v=gotip
Reports different output.
What did you expect to see?
I expected all output to be
NaN
.What did you see instead?
min()
/max()
are returningNaN
andmath.Min()
/math.Max()
are returning-Inf
/+Inf
.I think the output of the
math
versions is wrong as it should check forNaN
before the infinities, but I don't have a copy of 754 right now and what min/max is under 754 is special (e.g. see minNum in IEEE 754-2008 vs. minimum & minimumNumber in IEEE 754-2019.The text was updated successfully, but these errors were encountered: