當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


GO LeadingZeros16用法及代碼示例

GO語言"math/bits"包中"LeadingZeros16"函數的用法及代碼示例。

用法:

func LeadingZeros16(x uint16) int

LeadingZeros16 返回 x 中前導零的位數;對於 x == 0,結果為 16。

例子:

package main

import (
    "fmt"
    "math/bits"
)

func main() {
    fmt.Printf("LeadingZeros16(%016b) = %d\n", 1, bits.LeadingZeros16(1))
}

輸出:

LeadingZeros16(0000000000000001) = 15

相關用法


注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 LeadingZeros16。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。