diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-02-14 13:23:51 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-02-14 13:23:51 +0100 |
commit | 758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch) | |
tree | 6d6b34f8c678862fe9b56c945a7b63f68502c245 /doc/go_faq.html | |
parent | 3e45412327a2654a77944249962b3652e6142299 (diff) | |
download | golang-upstream/2011-02-01.1.tar.gz |
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'doc/go_faq.html')
-rw-r--r-- | doc/go_faq.html | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/doc/go_faq.html b/doc/go_faq.html index 1c7b85ef8..3f9c1d246 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -665,11 +665,16 @@ of Effective Go</a> for more details. Why is <code>int</code> 32 bits on 64 bit machines?</h3> <p> -The size of <code>int</code> and <code>float</code> is implementation-specific. +The sizes of <code>int</code> and <code>uint</code> 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 <code>int</code> and <code>float</code>. Code that relies on a particular -size of value should use an explicitly sized type, like <code>int64</code> or -<code>float64</code>. +<code>int</code>. Code that relies on a particular +size of value should use an explicitly sized type, like <code>int64</code>. +On the other hand, floating-point scalars and complex +numbers are always sized: <code>float32</code>, <code>complex64</code>, +etc., because programmers should be aware of precision when using +floating-point numbers. +The default size of a floating-point constant is <code>float64</code>. </p> <h2 id="Concurrency">Concurrency</h2> @@ -788,7 +793,7 @@ Consider the following program: func main() { done := make(chan bool) - values = []string{ "a", "b", "c" } + values := []string{ "a", "b", "c" } for _, v := range values { go func() { fmt.Println(v) @@ -797,7 +802,7 @@ func main() { } // wait for all goroutines to complete before exiting - for i := range values { + for _ = range values { <-done } } @@ -818,7 +823,7 @@ could modify the inner loop to read: <pre> for _, v := range values { - go func(<b>u</b>) { + go func(<b>u</b> string) { fmt.Println(<b>u</b>) done <- true }(<b>v</b>) |