Standard library / math/bits

bits.ReverseBytes16()

Reverses byte order within the word; useful for explicit byte-order conversion. Expected stdout: '4660\n'.

Formal Syntax & Structure

go syntaxgo
func ReverseBytes16(x uint16) uint16

Parameters & Attributes

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

Return Value

uint16

Reverses byte order within the word; useful for explicit byte-order conversion.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/bits")
func main() {  fmt.Println(bits.ReverseBytes16(bits.ReverseBytes16(0x1234)))}
Go Reference