From: Terrel Shumway Date: Tue, 30 Aug 2016 13:58:52 +0000 (-0600) Subject: doc: clarify FAQ wording for float sizes X-Git-Tag: go1.8beta1~1574 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fcb45e7ceff09548eb0308909256296086eedf9c;p=gostls13.git doc: clarify FAQ wording for float sizes I was confused by the current wording. This wording answers the question more clearly. Thanks to Robert Griesemer for suggestions. Fixes #16916 Change-Id: I50187c8df2db661b9581f4b3c5d5c279d2f9af41 Reviewed-on: https://go-review.googlesource.com/28052 Reviewed-by: Robert Griesemer --- diff --git a/doc/go_faq.html b/doc/go_faq.html index 50108c075b..905bf9c9a3 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -1262,11 +1262,17 @@ size of value should use an explicitly sized type, like int64. Prior to Go 1.1, the 64-bit Go compilers (both gc and gccgo) used a 32-bit representation for int. As of Go 1.1 they use a 64-bit representation. +

+ +

On the other hand, floating-point scalars and complex -numbers are always sized: float32, complex64, -etc., because programmers should be aware of precision when using -floating-point numbers. -The default size of a floating-point constant is float64. +types are always sized (there are no float or complex basic types), +because programmers should be aware of precision when using floating-point numbers. +The default type used for an (untyped) floating-point constant is float64. +Thus foo := 3.0 declares a variable foo of type float64. +For a float32 variable initialized by a constant, the variable type must be specified explicitly +in the variable declaration var foo float32 = 3.0, or the constant must be given a +type with a conversion as in foo := float32(3.0).