aboutsummaryrefslogtreecommitdiff
path: root/src/math/bits/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/bits/example_test.go')
-rw-r--r--src/math/bits/example_test.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/math/bits/example_test.go b/src/math/bits/example_test.go
index 18e026b9b4..b2ed2cba4b 100644
--- a/src/math/bits/example_test.go
+++ b/src/math/bits/example_test.go
@@ -59,6 +59,12 @@ func ExampleTrailingZeros64() {
// TrailingZeros64(0000000000000000000000000000000000000000000000000000000000001110) = 1
}
+func ExampleOnesCount() {
+ fmt.Printf("OnesCount(%b) = %d\n", 14, bits.OnesCount(14))
+ // Output:
+ // OnesCount(1110) = 3
+}
+
func ExampleOnesCount8() {
fmt.Printf("OnesCount8(%08b) = %d\n", 14, bits.OnesCount8(14))
// Output: