doc/devel/roadmap.html | 5 ++--- doc/effective_go.html | 9 +++++---- doc/gccgo_install.html | 4 ++-- doc/go_faq.html | 13 +++++++++---- doc/go_for_cpp_programmers.html | 2 +- doc/go_tutorial.html | 20 +++++++++++++------- doc/go_tutorial.txt | 20 +++++++++++++------- doc/install.html | 7 +++---- doc/progs/sort.go | 12 ++++++------ diff --git a/doc/devel/roadmap.html b/doc/devel/roadmap.html index 021ed6478a03a6330416dcccae8317a13f63ba61..9a3c4eaba5bb78d1d5545fbcb568330550eec9e5 100644 --- a/doc/devel/roadmap.html +++ b/doc/devel/roadmap.html @@ -58,8 +58,6 @@ Implement goto restrictions.
-func Sum(a *[3]float) (sum float) {
+func Sum(a *[3]float64) (sum float64) {
for _, v := range *a {
sum += v
}
return
}
-array := [...]float{7.0, 8.5, 9.1}
+array := [...]float64{7.0, 8.5, 9.1}
x := Sum(&array) // Note the explicit address-of operator
@@ -1233,7 +1233,8 @@ Maps are a convenient and powerful built-in data structure to associate
values of different types.
The key can be of any type for which the equality operator is defined,
such as integers,
-floats, strings, pointers, and interfaces (as long as the dynamic type
+floating point and complex numbers,
+strings, pointers, and interfaces (as long as the dynamic type
supports equality). Structs, arrays and slices cannot be used as map keys,
because equality is not defined on those types.
Like slices, maps are a reference type. If you pass a map to a function
@@ -1806,7 +1807,7 @@ Because the two types (Sequence and []int)
are the same if we ignore the type name, it's legal to convert between them.
The conversion doesn't create a new value, it just temporarily acts
as though the existing value has a new type.
-(There are other legal conversions, such as from integer to float, that
+(There are other legal conversions, such as from integer to floating point, that
do create a new value.)
diff --git a/doc/gccgo_install.html b/doc/gccgo_install.html index 393e57963b4e96311a21e09c7862ec42c179a207..2ab6dcdae9e54845b2071fa4b10832cc63b70d25 100644 --- a/doc/gccgo_install.html +++ b/doc/gccgo_install.html @@ -296,8 +296,8 @@ than one value, the C function returns a struct. For example, these functions have equivalent types:
-func GoFunction(int) (int, float)
-struct { int i; float f; } CFunction(int)
+func GoFunction(int) (int, float64)
+struct { int i; float64 f; } CFunction(int)
diff --git a/doc/go_faq.html b/doc/go_faq.html index 1c7b85ef8961cf22dc9dd62c084b67f87a90376f..f923a6ae291354d7211ffc90e1a66915625541a4 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -665,11 +665,16 @@
int 32 bits on 64 bit machines?
-The size of int and float is implementation-specific.
+The sizes of int and uint are implementation-specific
+but the same as each other on a given platform.
The 64 bit Go compilers (both 6g and gccgo) use a 32 bit representation for
-both int and float. Code that relies on a particular
-size of value should use an explicitly sized type, like int64 or
-float64.
+int. Code that relies on a particular
+size of value should use an explicitly sized type, like int64.
+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.
var (
i int
- m float
+ m float64
)
diff --git a/doc/go_tutorial.html b/doc/go_tutorial.html
index e3d966b874eba6d32c780f3bff6a6bcc9a0673e7..ece22036ae6134cd48caf1ec39060056cce6815c 100644
--- a/doc/go_tutorial.html
+++ b/doc/go_tutorial.html
@@ -238,13 +238,18 @@ flag package to access the command-line arguments.
-Go has some familiar types such as int and float, which represent
+Go has some familiar types such as int and uint (unsigned int), which represent
values of the ''appropriate'' size for the machine. It also defines
explicitly-sized types such as int8, float64, and so on, plus
-unsigned integer types such as uint, uint32, etc. These are
-distinct types; even if int and int32 are both 32 bits in size,
+unsigned integer types such as uint, uint32, etc.
+These are distinct types; even if int and int32 are both 32 bits in size,
they are not the same type. There is also a byte synonym for
uint8, which is the element type for strings.
+
+Floating-point types are always sized: float32 and float64,
+plus complex64 (two float32s) and complex128
+(two float64s). Complex numbers are outside the
+scope of this tutorial.
Speaking of string, that's a built-in type as well. Strings are
immutable values—they are not just arrays of byte values.
@@ -452,14 +457,15 @@ var a uint64 = 0 // a has type uint64, value 0
a := uint64(0) // equivalent; uses a "conversion"
i := 0x1234 // i gets default type: int
var j int = 1e6 // legal - 1000000 is representable in an int
- x := 1.5 // a float
+ x := 1.5 // a float64, the default type for floating constants
i3div2 := 3/2 // integer division - result is 1
- f3div2 := 3./2. // floating point division - result is 1.5
+ f3div2 := 3./2. // floating-point division - result is 1.5
Conversions only work for simple cases such as converting ints of one
-sign or size to another, and between ints and floats, plus a few other
-simple cases. There are no automatic numeric conversions of any kind in Go,
+sign or size to another and between integers and floating-point numbers,
+plus a couple of other instances outside the scope of a tutorial.
+There are no automatic numeric conversions of any kind in Go,
other than that of making constants have concrete size and type when
assigned to a variable.
diff --git a/doc/go_tutorial.txt b/doc/go_tutorial.txt
index bf07330a8715faa6ea4cd2093dd3c61084f652ea..5eea3c980bbb0e7924054443e3344953326f6b67 100644
--- a/doc/go_tutorial.txt
+++ b/doc/go_tutorial.txt
@@ -189,13 +189,18 @@
An Interlude about Types
----
-Go has some familiar types such as "int" and "float", which represent
+Go has some familiar types such as "int" and "uint" (unsigned "int"), which represent
values of the ''appropriate'' size for the machine. It also defines
explicitly-sized types such as "int8", "float64", and so on, plus
-unsigned integer types such as "uint", "uint32", etc. These are
-distinct types; even if "int" and "int32" are both 32 bits in size,
+unsigned integer types such as "uint", "uint32", etc.
+These are distinct types; even if "int" and "int32" are both 32 bits in size,
they are not the same type. There is also a "byte" synonym for
"uint8", which is the element type for strings.
+
+Floating-point types are always sized: "float32" and "float64",
+plus "complex64" (two "float32s") and "complex128"
+(two "float64s"). Complex numbers are outside the
+scope of this tutorial.
Speaking of "string", that's a built-in type as well. Strings are
immutable values—they are not just arrays of "byte" values.
@@ -362,13 +367,14 @@ var a uint64 = 0 // a has type uint64, value 0
a := uint64(0) // equivalent; uses a "conversion"
i := 0x1234 // i gets default type: int
var j int = 1e6 // legal - 1000000 is representable in an int
- x := 1.5 // a float
+ x := 1.5 // a float64, the default type for floating constants
i3div2 := 3/2 // integer division - result is 1
- f3div2 := 3./2. // floating point division - result is 1.5
+ f3div2 := 3./2. // floating-point division - result is 1.5
Conversions only work for simple cases such as converting "ints" of one
-sign or size to another, and between "ints" and "floats", plus a few other
-simple cases. There are no automatic numeric conversions of any kind in Go,
+sign or size to another and between integers and floating-point numbers,
+plus a couple of other instances outside the scope of a tutorial.
+There are no automatic numeric conversions of any kind in Go,
other than that of making constants have concrete size and type when
assigned to a variable.
diff --git a/doc/install.html b/doc/install.html
index 92b099fe8d92f5f2713cc8c2f480cee5d3957abc..5917da964a169ca87c4d0bfc5f28ce6e1d396ba2 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -45,11 +45,10 @@ arm (a.k.a. ARM); 5g,5l,5c,5a