-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
02-01_manipulating_rightmost_bits_test.go
72 lines (57 loc) · 1.59 KB
/
02-01_manipulating_rightmost_bits_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package hd_test
import (
"fmt"
hd "github.com/nikolaydubina/go-hackers-delight"
)
func ExampleTurnOffRightMostBit() {
fmt.Printf("%08b", hd.TurnOffRightMostBit(0b01011000))
// Output: 01010000
}
func ExampleTurnOnRightMostBit() {
fmt.Printf("%08b", hd.TurnOnRightMostBit(0b10100111))
// Output: 10101111
}
func ExampleTurnOffTrailingOnes() {
fmt.Printf("%08b", hd.TurnOffTrailingOnes(0b10100111))
// Output: 10100000
}
func ExampleTurnOnTrailingZeros() {
fmt.Printf("%08b", hd.TurnOnTrailingZeros(0b10101000))
// Output: 10101111
}
func ExampleSetBitLastZero() {
fmt.Printf("%08b", hd.SetBitLastZero(0b10100111))
// Output: 00001000
}
func ExampleSetTrailingZeros() {
fmt.Printf("%08b", hd.SetTrailingZeros(0b01011000))
// Output: 00000111
}
func ExampleSetTrailingZeros2() {
fmt.Printf("%08b", hd.SetTrailingZeros2(0b01011000))
// Output: 00000111
}
func ExampleSetTrailingZeros3() {
fmt.Printf("%08b", hd.SetTrailingZeros3(0b01011000))
// Output: 00000111
}
func ExampleIsolateRightmostOneBit() {
fmt.Printf("%08b", hd.IsolateRightmostOneBit(0b01011000))
// Output: 00001000
}
func ExampleSetTrailingZerosWithRightMostOne() {
fmt.Printf("%08b", hd.SetTrailingZerosWithRightMostOne(0b01011000))
// Output: 00001111
}
func ExampleSetTrailingOnesWithRightMostOne() {
fmt.Printf("%08b", hd.SetTrailingOnesWithRightMostOne(0b01010111))
// Output: 00001111
}
func ExampleTurnOffRightmostOnes() {
fmt.Printf("%08b", hd.TurnOffRightmostOnes(0b01011100))
// Output: 01000000
}
func ExampleTurnOffRightmostOnes2() {
fmt.Printf("%08b", hd.TurnOffRightmostOnes2(0b01011100))
// Output: 01000000
}