int.go
753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s
// CHECK: 2147483647
// CHECK-NEXT: 2147483647
// CHECK-NEXT: 2147483647
// CHECK-NEXT: 2147483648
// CHECK-NEXT: -2147483648
// CHECK-NEXT: 18446744071562067968
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: -1
// CHECK-NEXT: 4294967295
// CHECK-NEXT: 4294967295
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 1
// CHECK-NEXT: 1
// CHECK-NEXT: 1
package main
func signed(i32 int32) {
println(uint32(i32))
println(int64(i32))
println(uint64(i32))
}
func unsigned(u32 uint32) {
println(int32(u32))
println(int64(u32))
println(uint64(u32))
}
func main() {
signed(1<<31 - 1)
signed(-1 << 31)
signed(0)
unsigned(1<<32 - 1)
unsigned(0)
unsigned(1)
}