Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(167)

Side by Side Diff: test/divide.go

Issue 4798062: code review 4798062: 6g, 8g: divide corner case (Closed)
Patch Set: diff -r 2313a84d4d4b https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/8g/ggen.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // $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 }
OLDNEW
« no previous file with comments | « src/cmd/8g/ggen.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b