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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [divide.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 2011 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
// divide corner cases
8
 
9
package main
10
 
11
import "fmt"
12
 
13
func f8(x, y, q, r int8) {
14
        if t := x / y; t != q {
15
                fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q)
16
        }
17
        if t := x % y; t != r {
18
                fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r)
19
        }
20
}
21
 
22
func f16(x, y, q, r int16) {
23
        if t := x / y; t != q {
24
                fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q)
25
        }
26
        if t := x % y; t != r {
27
                fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r)
28
        }
29
}
30
 
31
func f32(x, y, q, r int32) {
32
        if t := x / y; t != q {
33
                fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q)
34
        }
35
        if t := x % y; t != r {
36
                fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r)
37
        }
38
}
39
 
40
func f64(x, y, q, r int64) {
41
        if t := x / y; t != q {
42
                fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q)
43
        }
44
        if t := x % y; t != r {
45
                fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r)
46
        }
47
}
48
 
49
func main() {
50
        f8(-1<<7, -1, -1<<7, 0)
51
        f16(-1<<15, -1, -1<<15, 0)
52
        f32(-1<<31, -1, -1<<31, 0)
53
        f64(-1<<63, -1, -1<<63, 0)
54
}

powered by: WebSVN 2.1.0

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