OSDN Git Service

Remove the types float and complex.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / ken / cplx4.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import "fmt"
10
11 const (
12         R = 5
13         I = 6i
14
15         C1 = R + I // ADD(5,6)
16 )
17
18 func doprint(c complex128) { fmt.Printf("c = %f\n", c) }
19
20 func main() {
21
22         // constants
23         fmt.Printf("c = %f\n", -C1)
24         doprint(C1)
25
26         // variables
27         c1 := C1
28         fmt.Printf("c = %f\n", c1)
29         doprint(c1)
30
31         // 128
32         c2 := complex128(C1)
33         fmt.Printf("c = %G\n", c2)
34
35         // real, imag, complex
36         c3 := complex(real(c2)+3, imag(c2)-5) + c2
37         fmt.Printf("c = %G\n", c3)
38
39         // compiler used to crash on nested divide
40         c4 := complex(real(c3/2), imag(c3/2))
41         if c4 != c3/2 {
42                 fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4)
43         }
44 }