We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Please answer these questions before submitting your issue. Thanks!
go version
go version go1.9.2 linux/amd64
I believe go1.9.2 is the latest release.
go env
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/usr/local/google/home/majnemer/go" GORACE="" GOROOT="/usr/lib/google-golang" GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build846653371=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"
I ran the following program: https://play.golang.org/p/_lUAaRG9D-P
The documentation for math.Pow says the following:
Pow(±0, y) = +0 for finite y > 0 and not an odd integer
.5 is finite and not an odd integer which means math.Pow should give back +0.
math.Pow gave back -0.
The text was updated successfully, but these errors were encountered:
Change https://golang.org/cl/85415 mentions this issue: math: Fixed wrong result for sqrt(-0)
math: Fixed wrong result for sqrt(-0)
Sorry, something went wrong.
Thank you for reporting this issue @majnemer, I'll loop in @griesemer.
There is another, related bug. Consider: Pow(-Inf, 0.5) == Pow(-0, -0.5) == Pow(±0, y) = +Inf
However, Go gives me back NaN.
I believe the original bug and the one I have just noted if we change the line:
return Sqrt(x)
into something along the lines of the following:
if IsInf(x, -1) { return Inf(1) } return Abs(Sqrt(x))
Change https://golang.org/cl/85660 mentions this issue: math: correct result for Pow(x, ±.5)
math: correct result for Pow(x, ±.5)
5305bdd
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
I believe go1.9.2 is the latest release.
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/majnemer/go"
GORACE=""
GOROOT="/usr/lib/google-golang"
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build846653371=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
I ran the following program: https://play.golang.org/p/_lUAaRG9D-P
What did you expect to see?
The documentation for math.Pow says the following:
.5 is finite and not an odd integer which means math.Pow should give back +0.
What did you see instead?
math.Pow gave back -0.
The text was updated successfully, but these errors were encountered: