From: Carl Shapiro Date: Tue, 10 Dec 2013 01:51:30 +0000 (-0800) Subject: runtime: check for signed zero in printfloat X-Git-Tag: go1.3beta1~1282 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f574726f16887112e9165f9fd0b8832eada76c2f;p=gostls13.git runtime: check for signed zero in printfloat Fixes #6899 R=golang-dev, r, cshapiro, iant, rsc CC=golang-dev https://golang.org/cl/38120043 --- diff --git a/src/pkg/runtime/print.c b/src/pkg/runtime/print.c index 8de3ae4fa1..edb5a1c2ee 100644 --- a/src/pkg/runtime/print.c +++ b/src/pkg/runtime/print.c @@ -236,7 +236,10 @@ runtime·printfloat(float64 v) n = 7; // digits printed e = 0; // exp s = 0; // sign - if(v != 0) { + if(v == 0) { + if(1/v == runtime·neginf) + s = 1; + } else { // sign if(v < 0) { v = -v; diff --git a/test/fixedbugs/issue6899.go b/test/fixedbugs/issue6899.go new file mode 100644 index 0000000000..a693bf2850 --- /dev/null +++ b/test/fixedbugs/issue6899.go @@ -0,0 +1,13 @@ +// cmpout + +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "math" + +func main() { + println(math.Copysign(0, -1)) +} diff --git a/test/fixedbugs/issue6899.out b/test/fixedbugs/issue6899.out new file mode 100644 index 0000000000..e2375f0776 --- /dev/null +++ b/test/fixedbugs/issue6899.out @@ -0,0 +1 @@ +-0.000000e+000