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.Signbit(-float64(0)) is false #2196
Labels
Comments
What you are seeing is a mismatch between the run time behavior of floating point numbers and the ideal constant evaluation in the Go compiler. They're different: the constants in Go are just that: constants. There's no infinity, no NaN, no negative zero. Those are all IEEE754 concepts, so they exist at run time, but not in the compiler. If you want an IEEE754 negative zero, you can be explicit by using math.Copysign. Russ |
Owner changed to @rsc. Status changed to WorkingAsIntended. |
From the language spec ( http://golang.org/doc/go_spec.html#Conversions ) "Converting a constant yields a typed constant as result." " float32(2.718281828) // 2.718281828 of type float32" "The values of typed constants must always be accurately representable as values of the constant type." so I expect float64(0) is not an ideal constant, but is a typed constant of type float64, and the negation operator applied to that should behave as advertised in "For floating-point numbers, +x is the same as x, while -x is the negation of x." |
CL https://golang.org/cl/14261 mentions this issue. |
gopherbot
pushed a commit
that referenced
this issue
Sep 10, 2015
This matches existing behavior, see issue #2196 Change-Id: Ifa9359b7c821115389f337a57de355c5ec23be8f Reviewed-on: https://go-review.googlesource.com/14261 Reviewed-by: Keith Randall <khr@golang.org>
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by mikesamuel:
The text was updated successfully, but these errors were encountered: