From: Robert Griesemer 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)
.
+Thus foo
:=
3.0
declares a variable foo
+of type float64
.
+For a float32
variable initialized by an (untyped) constant, the variable type
+must be specified explicitly in the variable declaration:
+
+var foo float32 = 3.0 ++ +
+Alternatively, the constant must be given a type with a conversion as in
+foo := float32(3.0)
.