UInt32

The UInt32 module provides functions for working with 32-bit unsigned integers. Use UInt32 for binary data manipulation, bitwise operations, hash values, and when interfacing with system APIs that use unsigned 32-bit integers.

Common Use Cases

UInt32 is commonly used for: color values (RGBA), file sizes, network protocols, binary file formats, and hash function outputs.

Overview

UInt32 represents unsigned integers in the range 0 to 4,294,967,295 (2^32 - 1).

Creation

UInt32.from-int
Int -> UInt32
Converts a non-negative Int to UInt32. Values are truncated to 32 bits.
n = UInt32.from-int 255
println n

Arithmetic

UInt32 supports unsigned arithmetic operations with wraparound behavior: add, sub, mul, div, and mod.

Bitwise Operations

UInt32 provides bitwise operations for binary manipulation:

UInt32.band
UInt32 -> UInt32 -> UInt32
Bitwise AND of two UInt32 values.
UInt32.bor
UInt32 -> UInt32 -> UInt32
Bitwise OR of two UInt32 values.
UInt32.bxor
UInt32 -> UInt32 -> UInt32
Bitwise XOR of two UInt32 values.
UInt32.shl
UInt32 -> Int -> UInt32
Shift left by n bits.
UInt32.shr
UInt32 -> Int -> UInt32
Shift right by n bits (logical shift, zero-filled).

Conversion

UInt32.to-int
UInt32 -> Int
Converts a UInt32 to a signed Int.
UInt32.to-string
UInt32 -> String
Converts a UInt32 to its decimal string representation.
UInt32.to-hex
UInt32 -> String
Converts a UInt32 to its hexadecimal string representation.