From: adarsh ravichandran Date: Mon, 20 May 2019 10:57:13 +0000 (+0530) Subject: math/bits: add example for OnesCount function X-Git-Tag: go1.13beta1~245 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=776e1709e59c2c50d93467e666d4bb8955b32ed3;p=gostls13.git math/bits: add example for OnesCount function Change-Id: Id87db9bed5e8715d554c1bf95c063d7d0a03c3e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/178117 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- 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: