| | |
| | |
| | |
| |
|
| | |
| |
|
| | package bits_test |
| |
|
| | import ( |
| | "fmt" |
| | "math/bits" |
| | ) |
| |
|
| | func ExampleLeadingZeros8() { |
| | fmt.Printf("LeadingZeros8(%08b) = %d\n", 1, bits.LeadingZeros8(1)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLeadingZeros16() { |
| | fmt.Printf("LeadingZeros16(%016b) = %d\n", 1, bits.LeadingZeros16(1)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLeadingZeros32() { |
| | fmt.Printf("LeadingZeros32(%032b) = %d\n", 1, bits.LeadingZeros32(1)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLeadingZeros64() { |
| | fmt.Printf("LeadingZeros64(%064b) = %d\n", 1, bits.LeadingZeros64(1)) |
| | |
| | |
| | } |
| |
|
| | func ExampleTrailingZeros8() { |
| | fmt.Printf("TrailingZeros8(%08b) = %d\n", 14, bits.TrailingZeros8(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleTrailingZeros16() { |
| | fmt.Printf("TrailingZeros16(%016b) = %d\n", 14, bits.TrailingZeros16(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleTrailingZeros32() { |
| | fmt.Printf("TrailingZeros32(%032b) = %d\n", 14, bits.TrailingZeros32(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleTrailingZeros64() { |
| | fmt.Printf("TrailingZeros64(%064b) = %d\n", 14, bits.TrailingZeros64(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleOnesCount() { |
| | fmt.Printf("OnesCount(%b) = %d\n", 14, bits.OnesCount(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleOnesCount8() { |
| | fmt.Printf("OnesCount8(%08b) = %d\n", 14, bits.OnesCount8(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleOnesCount16() { |
| | fmt.Printf("OnesCount16(%016b) = %d\n", 14, bits.OnesCount16(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleOnesCount32() { |
| | fmt.Printf("OnesCount32(%032b) = %d\n", 14, bits.OnesCount32(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleOnesCount64() { |
| | fmt.Printf("OnesCount64(%064b) = %d\n", 14, bits.OnesCount64(14)) |
| | |
| | |
| | } |
| |
|
| | func ExampleRotateLeft8() { |
| | fmt.Printf("%08b\n", 15) |
| | fmt.Printf("%08b\n", bits.RotateLeft8(15, 2)) |
| | fmt.Printf("%08b\n", bits.RotateLeft8(15, -2)) |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleRotateLeft16() { |
| | fmt.Printf("%016b\n", 15) |
| | fmt.Printf("%016b\n", bits.RotateLeft16(15, 2)) |
| | fmt.Printf("%016b\n", bits.RotateLeft16(15, -2)) |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleRotateLeft32() { |
| | fmt.Printf("%032b\n", 15) |
| | fmt.Printf("%032b\n", bits.RotateLeft32(15, 2)) |
| | fmt.Printf("%032b\n", bits.RotateLeft32(15, -2)) |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleRotateLeft64() { |
| | fmt.Printf("%064b\n", 15) |
| | fmt.Printf("%064b\n", bits.RotateLeft64(15, 2)) |
| | fmt.Printf("%064b\n", bits.RotateLeft64(15, -2)) |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverse8() { |
| | fmt.Printf("%08b\n", 19) |
| | fmt.Printf("%08b\n", bits.Reverse8(19)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverse16() { |
| | fmt.Printf("%016b\n", 19) |
| | fmt.Printf("%016b\n", bits.Reverse16(19)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverse32() { |
| | fmt.Printf("%032b\n", 19) |
| | fmt.Printf("%032b\n", bits.Reverse32(19)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverse64() { |
| | fmt.Printf("%064b\n", 19) |
| | fmt.Printf("%064b\n", bits.Reverse64(19)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverseBytes16() { |
| | fmt.Printf("%016b\n", 15) |
| | fmt.Printf("%016b\n", bits.ReverseBytes16(15)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverseBytes32() { |
| | fmt.Printf("%032b\n", 15) |
| | fmt.Printf("%032b\n", bits.ReverseBytes32(15)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleReverseBytes64() { |
| | fmt.Printf("%064b\n", 15) |
| | fmt.Printf("%064b\n", bits.ReverseBytes64(15)) |
| | |
| | |
| | |
| | } |
| |
|
| | func ExampleLen8() { |
| | fmt.Printf("Len8(%08b) = %d\n", 8, bits.Len8(8)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLen16() { |
| | fmt.Printf("Len16(%016b) = %d\n", 8, bits.Len16(8)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLen32() { |
| | fmt.Printf("Len32(%032b) = %d\n", 8, bits.Len32(8)) |
| | |
| | |
| | } |
| |
|
| | func ExampleLen64() { |
| | fmt.Printf("Len64(%064b) = %d\n", 8, bits.Len64(8)) |
| | |
| | |
| | } |
| |
|