diff options
Diffstat (limited to 'src/math/bits/example_test.go')
| -rw-r--r-- | src/math/bits/example_test.go | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/math/bits/example_test.go b/src/math/bits/example_test.go index 3d6ec53d29..f4ed259043 100644 --- a/src/math/bits/example_test.go +++ b/src/math/bits/example_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Code generated by go run make_examples.go. DO NOT EDIT. + package bits_test import ( @@ -33,52 +35,52 @@ func ExampleLeadingZeros64() { // LeadingZeros64(0000000000000000000000000000000000000000000000000000000000000001) = 63 } -func ExampleOnesCount8() { - fmt.Printf("OnesCount8(%08b) = %d\n", 14, bits.OnesCount8(14)) +func ExampleTrailingZeros8() { + fmt.Printf("TrailingZeros8(%08b) = %d\n", 14, bits.TrailingZeros8(14)) // Output: - // OnesCount8(00001110) = 3 + // TrailingZeros8(00001110) = 1 } -func ExampleOnesCount16() { - fmt.Printf("OnesCount16(%016b) = %d\n", 14, bits.OnesCount16(14)) +func ExampleTrailingZeros16() { + fmt.Printf("TrailingZeros16(%016b) = %d\n", 14, bits.TrailingZeros16(14)) // Output: - // OnesCount16(0000000000001110) = 3 + // TrailingZeros16(0000000000001110) = 1 } -func ExampleOnesCount32() { - fmt.Printf("OnesCount32(%032b) = %d\n", 14, bits.OnesCount32(14)) +func ExampleTrailingZeros32() { + fmt.Printf("TrailingZeros32(%032b) = %d\n", 14, bits.TrailingZeros32(14)) // Output: - // OnesCount32(00000000000000000000000000001110) = 3 + // TrailingZeros32(00000000000000000000000000001110) = 1 } -func ExampleOnesCount64() { - fmt.Printf("OnesCount64(%064b) = %d\n", 14, bits.OnesCount64(14)) +func ExampleTrailingZeros64() { + fmt.Printf("TrailingZeros64(%064b) = %d\n", 14, bits.TrailingZeros64(14)) // Output: - // OnesCount64(0000000000000000000000000000000000000000000000000000000000001110) = 3 + // TrailingZeros64(0000000000000000000000000000000000000000000000000000000000001110) = 1 } -func ExampleTrailingZeros8() { - fmt.Printf("TrailingZeros8(%08b) = %d\n", 8, bits.TrailingZeros8(8)) +func ExampleOnesCount8() { + fmt.Printf("OnesCount8(%08b) = %d\n", 14, bits.OnesCount8(14)) // Output: - // TrailingZeros8(00001000) = 3 + // OnesCount8(00001110) = 3 } -func ExampleTrailingZeros16() { - fmt.Printf("TrailingZeros16(%016b) = %d\n", 8, bits.TrailingZeros16(8)) +func ExampleOnesCount16() { + fmt.Printf("OnesCount16(%016b) = %d\n", 14, bits.OnesCount16(14)) // Output: - // TrailingZeros16(0000000000001000) = 3 + // OnesCount16(0000000000001110) = 3 } -func ExampleTrailingZeros32() { - fmt.Printf("TrailingZeros32(%032b) = %d\n", 8, bits.TrailingZeros32(8)) +func ExampleOnesCount32() { + fmt.Printf("OnesCount32(%032b) = %d\n", 14, bits.OnesCount32(14)) // Output: - // TrailingZeros32(00000000000000000000000000001000) = 3 + // OnesCount32(00000000000000000000000000001110) = 3 } -func ExampleTrailingZeros64() { - fmt.Printf("TrailingZeros64(%064b) = %d\n", 8, bits.TrailingZeros64(8)) +func ExampleOnesCount64() { + fmt.Printf("OnesCount64(%064b) = %d\n", 14, bits.OnesCount64(14)) // Output: - // TrailingZeros64(0000000000000000000000000000000000000000000000000000000000001000) = 3 + // OnesCount64(0000000000000000000000000000000000000000000000000000000000001110) = 3 } func ExampleLen8() { @@ -105,6 +107,14 @@ func ExampleLen64() { // Len64(0000000000000000000000000000000000000000000000000000000000001000) = 4 } +func ExampleReverse8() { + fmt.Printf("%08b\n", 19) + fmt.Printf("%08b\n", bits.Reverse8(19)) + // Output: + // 00010011 + // 11001000 +} + func ExampleReverse16() { fmt.Printf("%016b\n", 19) fmt.Printf("%016b\n", bits.Reverse16(19)) @@ -128,11 +138,3 @@ func ExampleReverse64() { // 0000000000000000000000000000000000000000000000000000000000010011 // 1100100000000000000000000000000000000000000000000000000000000000 } - -func ExampleReverse8() { - fmt.Printf("%008b\n", 19) - fmt.Printf("%008b\n", bits.Reverse8(19)) - // Output: - // 00010011 - // 11001000 -} |
