Commit 762a0bae authored by Wembley G. Leach, Jr's avatar Wembley G. Leach, Jr Committed by Josh Bleecher Snyder

math/bits: Add examples for Reverse functions

Change-Id: I30563d31f6acea594cc853cc6b672ec664f90d48
Reviewed-on: https://go-review.googlesource.com/53636Reviewed-by: 's avatarEmmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f776b9d5
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment