]> Cypherpunks repositories - gostls13.git/commitdiff
math/bits: Add examples for Reverse functions
authorWembley G. Leach, Jr <wembley.gl@gmail.com>
Tue, 8 Aug 2017 01:22:14 +0000 (21:22 -0400)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 9 Aug 2017 18:02:36 +0000 (18:02 +0000)
Change-Id: I30563d31f6acea594cc853cc6b672ec664f90d48
Reviewed-on: https://go-review.googlesource.com/53636
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/math/bits/example_test.go

index 5c64bb99de17d7b471761325c8dd65b2eeaf3aaf..3d6ec53d29acf32ab7faa32ab62cb4caba93c9f3 100644 (file)
@@ -104,3 +104,35 @@ func ExampleLen64() {
        // Output:
        // Len64(0000000000000000000000000000000000000000000000000000000000001000) = 4
 }
+
+func ExampleReverse16() {
+       fmt.Printf("%016b\n", 19)
+       fmt.Printf("%016b\n", bits.Reverse16(19))
+       // Output:
+       // 0000000000010011
+       // 1100100000000000
+}
+
+func ExampleReverse32() {
+       fmt.Printf("%032b\n", 19)
+       fmt.Printf("%032b\n", bits.Reverse32(19))
+       // Output:
+       // 00000000000000000000000000010011
+       // 11001000000000000000000000000000
+}
+
+func ExampleReverse64() {
+       fmt.Printf("%064b\n", 19)
+       fmt.Printf("%064b\n", bits.Reverse64(19))
+       // Output:
+       // 0000000000000000000000000000000000000000000000000000000000010011
+       // 1100100000000000000000000000000000000000000000000000000000000000
+}
+
+func ExampleReverse8() {
+       fmt.Printf("%008b\n", 19)
+       fmt.Printf("%008b\n", bits.Reverse8(19))
+       // Output:
+       // 00010011
+       // 11001000
+}