Standard library / math/bits

bits.RotateLeft()

Rotates bits left by k modulo the word width; negative k rotates right. Native uint width is architecture-dependent; local validation uses 64 bits. Expected stdout: '8\n'.

Formal Syntax & Structure

go syntaxgo
func RotateLeft(x uint, k int) uint

Parameters & Attributes

NameTypeDescription
xuintFirst input operand (or sole input if unary).
kintSigned rotation distance.

Return Value

uint

Rotates bits left by k modulo the word width; negative k rotates right. Native uint width is architecture-dependent; local validation uses 64 bits.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/bits")
func main() {  fmt.Println(bits.RotateLeft(1, 3))}
Go Reference