]> Cypherpunks repositories - gostls13.git/commit
spec: clarify numeric conversions where IEEE-754 produces -0.0
authorRobert Griesemer <gri@golang.org>
Fri, 18 Sep 2015 01:10:20 +0000 (18:10 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 20 Oct 2015 18:16:57 +0000 (18:16 +0000)
commit55ecda4ffd1899463db19bf224106fd73de21898
tree87fc5d929df3315c35a505feded90eed56c9a80b
parent27838f3990f345629b397f9f3902163392f08f9d
spec: clarify numeric conversions where IEEE-754 produces -0.0

The spec defines precise numeric constants which do not overflow.
Consequently, +/-Inf and NaN values were excluded. The case was not
clear for -0.0 but they are mostly of interest to determine the sign
of infinities which don't exist.

That said, the conversion rules explicitly say that T(x) (for a numeric
x and floating-point type T) is the value after rounding per IEEE-754.
The result is constant if x is constant. Rounding per IEEE-754 can
produce a -0.0 which we cannot represent as a constant.

Thus, the spec is inconsistent. Attempt to fix the inconsistency by
adjusting the rounding rule rather than letting -0.0 into the language.

For more details, see the issue below.

Open to discussion.

Fixes #12576.

Change-Id: Ibe3c676372ab16d9229f1f9daaf316f761e074ee
Reviewed-on: https://go-review.googlesource.com/14727
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
doc/go_spec.html