OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [cplx3.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $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 "unsafe"
10
import "reflect"
11
 
12
const (
13
        R = 5
14
        I = 6i
15
 
16
        C1 = R + I // ADD(5,6)
17
)
18
 
19
func main() {
20
        c0 := C1
21
        c0 = (c0 + c0 + c0) / (c0 + c0 + 3i)
22
        r, i := real(c0), imag(c0)
23
        d := r - 1.292308
24
        if d < 0 {
25
                d = - d
26
        }
27
        if d > 1e-6 {
28
                println(r, "!= 1.292308")
29
                panic(0)
30
        }
31
        d = i + 0.1384615
32
        if d < 0 {
33
                d = - d
34
        }
35
        if d > 1e-6 {
36
                println(i, "!= -0.1384615")
37
                panic(0)
38
        }
39
 
40
        c := *(*complex128)(unsafe.Pointer(&c0))
41
        if c != c0 {
42
                println(c, "!=", c)
43
                panic(0)
44
        }
45
 
46
        var a interface{}
47
        switch c := reflect.ValueOf(a); c.Kind() {
48
        case reflect.Complex64, reflect.Complex128:
49
                v := c.Complex()
50
                _, _ = complex128(v), true
51
        }
52
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.