runtime: check for signed zero in printfloat

Fixes #6899

R=golang-dev, r, cshapiro, iant, rsc
CC=golang-dev
https://golang.org/cl/38120043
This commit is contained in:
Carl Shapiro 2013-12-09 17:51:30 -08:00
parent 6ede93498c
commit f574726f16
3 changed files with 18 additions and 1 deletions

View file

@ -236,7 +236,10 @@ runtime·printfloat(float64 v)
n = 7; // digits printed n = 7; // digits printed
e = 0; // exp e = 0; // exp
s = 0; // sign s = 0; // sign
if(v != 0) { if(v == 0) {
if(1/v == runtime·neginf)
s = 1;
} else {
// sign // sign
if(v < 0) { if(v < 0) {
v = -v; v = -v;

View file

@ -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))
}

View file

@ -0,0 +1 @@
-0.000000e+000