diff options
| author | Wembley G. Leach, Jr <wembley.gl@gmail.com> | 2017-08-07 21:22:14 -0400 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-08-09 18:02:36 +0000 |
| commit | 762a0bae06b61f58a3783042167c54752c533aa1 (patch) | |
| tree | 24afe508b99a4b801683122fa141dbcfe3feb302 /src/math/bits/example_test.go | |
| parent | f776b9d5fa3577fe2fdaa3d2ef9d48adee329f9c (diff) | |
| download | go-762a0bae06b61f58a3783042167c54752c533aa1.tar.xz | |
math/bits: Add examples for Reverse functions
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>
Diffstat (limited to 'src/math/bits/example_test.go')
| -rw-r--r-- | src/math/bits/example_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
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 +} |
