From: Ian Lance Taylor Date: Mon, 13 Feb 2012 19:25:56 +0000 (-0800) Subject: spec: clarify implementation restrictions on untyped floats X-Git-Tag: weekly.2012-02-14~74 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9126c6570ce293761a4e5eefd61427902f291263;p=gostls13.git spec: clarify implementation restrictions on untyped floats Drop reference to "machine type." Specify that integer overflow must be an error. Drop requirement that exponent must be 128 bits--that's a lot. Clarify that floating point expressions may be rounded, including intermediate values. This is a reworking of https://golang.org/cl/5577068/ . Fixes #2789. R=r, rsc, r, gri, ken, ken, iant CC=golang-dev, remyoudompheng https://golang.org/cl/5655049 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 27c37c2ce1..7d4862f50d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -589,11 +589,33 @@ functions return and test for those values at run time.

-Implementation restriction: A compiler may implement numeric constants by choosing -an internal representation with at least twice as many bits as any machine type; -for floating-point values, both the mantissa and exponent must be twice as large. +Implementation restriction: Although numeric constants have arbitrary +precision in the language, a compiler may implement them using an +internal representation with limited precision. That said, every +implementation must:

+ +

+These requirements apply both to literal constants and to the result +of evaluating constant +expressions. +

Types

@@ -3574,6 +3596,16 @@ int8(^1) // same as int8(-2) ^int8(1) // same as -1 ^ int8(1) = -2 +

+Implementation restriction: A compiler may use rounding while +computing untyped floating-point or complex constant expressions; see +the implementation restriction in the section +on constants. This rounding may cause a +floating-point constant expression to be invalid in an integer +context, even if it would be integral when calculated using infinite +precision. +

+