Source file
test/fixedbugs/issue23812.go
1
2
3
4
5
6
7 package main
8
9 import "fmt"
10
11 func main() {
12 want := int32(0x3edae8)
13 got := foo(1)
14 if want != got {
15 panic(fmt.Sprintf("want %x, got %x", want, got))
16 }
17 }
18
19 func foo(a int32) int32 {
20 return shr1(int32(shr2(int64(0x14ff6e2207db5d1f), int(a))), 4)
21 }
22
23 func shr1(n int32, m int) int32 { return n >> uint(m) }
24
25 func shr2(n int64, m int) int64 {
26 if m < 0 {
27 m = -m
28 }
29 if m >= 64 {
30 return n
31 }
32
33 return n >> uint(m)
34 }
35
View as plain text