-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path02-17_double_length_shifts_test.go
35 lines (29 loc) · 1.05 KB
/
02-17_double_length_shifts_test.go
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
package hd_test
import (
"fmt"
hd "github.com/nikolaydubina/go-hackers-delight"
)
func ExampleShiftLeftDoubleLength() {
x := [2]uint32{0b1111, 0b1111}
y := hd.ShiftLeftDoubleLength(x, 3)
fmt.Printf("%032b_%032b", y[1], y[0])
// Output: 00000000000000000000000001111000_00000000000000000000000001111000
}
func ExampleShiftRightUnsignedDoubleLength() {
x := [2]uint32{0b1111, 0b1111}
y := hd.ShiftRightUnsignedDoubleLength(x, 3)
fmt.Printf("%032b_%032b", y[1], y[0])
// Output: 00000000000000000000000000000001_11100000000000000000000000000001
}
func ExampleShiftRightSignedDoubleLength() {
x := [2]uint32{0b1111, 0b1111}
y := hd.ShiftRightSignedDoubleLength(x, 3)
fmt.Printf("%032b_%032b", y[1], y[0])
// Output: 00000000000000000000000000000001_11100000000000000000000000000001
}
func ExampleShiftRightSignedDoubleLength_negative() {
x := [2]uint32{0b1111, 0b10000000000000000000000000000001}
y := hd.ShiftRightSignedDoubleLength(x, 3)
fmt.Printf("%032b_%032b", y[1], y[0])
// Output: 11110000000000000000000000000000_00100000000000000000000000000001
}