mirror of https://github.com/golang/go.git
math/bits: add examples for OnesCount functions
Change-Id: Ie673f9665825a40281c2584d478ba1260f725856 Reviewed-on: https://go-review.googlesource.com/53357 Run-TryBot: Chris Broadfoot <cbro@golang.org> Reviewed-by: Chris Broadfoot <cbro@golang.org>
This commit is contained in:
parent
b01db023b1
commit
9b1e7cf2ac
|
|
@ -36,3 +36,43 @@ func ExampleLeadingZeros64() {
|
|||
// 64
|
||||
// 63
|
||||
}
|
||||
|
||||
func ExampleOnesCount() {
|
||||
fmt.Printf("%b\n", 14)
|
||||
fmt.Println(bits.OnesCount(14))
|
||||
// Output:
|
||||
// 1110
|
||||
// 3
|
||||
}
|
||||
|
||||
func ExampleOnesCount8() {
|
||||
fmt.Printf("%b\n", 14)
|
||||
fmt.Println(bits.OnesCount8(14))
|
||||
// Output:
|
||||
// 1110
|
||||
// 3
|
||||
}
|
||||
|
||||
func ExampleOnesCount16() {
|
||||
fmt.Printf("%b\n", 14)
|
||||
fmt.Println(bits.OnesCount16(14))
|
||||
// Output:
|
||||
// 1110
|
||||
// 3
|
||||
}
|
||||
|
||||
func ExampleOnesCount32() {
|
||||
fmt.Printf("%b\n", 14)
|
||||
fmt.Println(bits.OnesCount32(14))
|
||||
// Output:
|
||||
// 1110
|
||||
// 3
|
||||
}
|
||||
|
||||
func ExampleOnesCount64() {
|
||||
fmt.Printf("%b\n", 14)
|
||||
fmt.Println(bits.OnesCount(14))
|
||||
// Output:
|
||||
// 1110
|
||||
// 3
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue