GO語言"math/bits"包中"OnesCount"函數的用法及代碼示例。
用法:
func OnesCount(x uint) int
OnesCount 返回 x 中一位 ("population count") 的數量。
例子:
package main
import (
"fmt"
"math/bits"
)
func main() {
fmt.Printf("OnesCount(%b) = %d\n", 14, bits.OnesCount(14))
}
輸出:
OnesCount(1110) = 3
相關用法
- GO OnesCount8用法及代碼示例
- GO OnesCount16用法及代碼示例
- GO OnesCount32用法及代碼示例
- GO OnesCount64用法及代碼示例
- GO Once用法及代碼示例
- GO OpenFile用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
- GO NewFromFiles用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Time.Sub用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
- GO Encode用法及代碼示例
- GO ResponseRecorder用法及代碼示例
- GO Value用法及代碼示例
- GO StreamWriter用法及代碼示例
- GO Fscanln用法及代碼示例
- GO Values.Get用法及代碼示例
- GO NumError用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 OnesCount。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。