From: Wembley G. Leach, Jr Date: Tue, 8 Aug 2017 01:22:14 +0000 (-0400) Subject: math/bits: Add examples for Reverse functions X-Git-Tag: go1.10beta1~1679 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=762a0bae06b61f58a3783042167c54752c533aa1;p=gostls13.git math/bits: Add examples for Reverse functions Change-Id: I30563d31f6acea594cc853cc6b672ec664f90d48 Reviewed-on: https://go-review.googlesource.com/53636 Reviewed-by: Emmanuel Odeke Reviewed-by: Josh Bleecher Snyder Run-TryBot: Emmanuel Odeke TryBot-Result: Gobot Gobot --- diff --git a/src/math/bits/example_test.go b/src/math/bits/example_test.go index 5c64bb99de..3d6ec53d29 100644 --- a/src/math/bits/example_test.go +++ b/src/math/bits/example_test.go @@ -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 +}