GO語言"math/bits"包中"RotateLeft32"函數的用法及代碼示例。
用法:
func RotateLeft32(x uint32, k int) uint32
RotateLeft32 返回 x 向左旋轉 (k mod 32) 位的值。要將 x 向右旋轉 k 位,請調用 RotateLeft32(x, -k)。
此函數的執行時間不依賴於輸入。
例子:
package main
import (
"fmt"
"math/bits"
)
func main() {
fmt.Printf("%032b\n", 15)
fmt.Printf("%032b\n", bits.RotateLeft32(15, 2))
fmt.Printf("%032b\n", bits.RotateLeft32(15, -2))
}
輸出:
00000000000000000000000000001111 00000000000000000000000000111100 11000000000000000000000000000011
相關用法
- GO RotateLeft64用法及代碼示例
- GO RotateLeft8用法及代碼示例
- GO RotateLeft16用法及代碼示例
- GO Rows用法及代碼示例
- GO RoundToEven用法及代碼示例
- GO Round用法及代碼示例
- GO RoundingMode用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
- GO ResponseRecorder用法及代碼示例
- GO ReverseBytes64用法及代碼示例
- GO ReverseBytes16用法及代碼示例
- GO Regexp.ReplaceAllLiteralString用法及代碼示例
- GO Regexp.FindStringSubmatch用法及代碼示例
- GO Regexp.FindAllString用法及代碼示例
- GO ReadMessage用法及代碼示例
- GO Regexp.ExpandString用法及代碼示例
- GO ResponseWriter用法及代碼示例
- GO Regexp.FindAllStringSubmatch用法及代碼示例
- GO Reverse用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 RotateLeft32。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。