Standard library / math/bits

bits.ReverseBytes()

Reverses byte order within the word; useful for explicit byte-order conversion. Native uint width is architecture-dependent; local validation uses 64 bits. Expected stdout: '4660\n'.

Formal Syntax & Structure

go syntaxgo
func ReverseBytes(x uint) uint

Parameters & Attributes

NameTypeDescription
xuintFirst input operand (or sole input if unary).

Return Value

uint

Reverses byte order within the word; useful for explicit byte-order conversion. 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.ReverseBytes(bits.ReverseBytes(0x1234)))}
Go Reference