Skip to content

int

The int module provides integer conversion, parsing, and bitwise operations. It is auto-imported — no import statement needed.

FunctionSignatureDescription
to_string(Int) -> StringDecimal string representation
to_hex(Int) -> StringHexadecimal string (lowercase)
to_float(Int) -> FloatConvert to float
to_u32(Int) -> IntTruncate to unsigned 32-bit (0..4294967295)
to_u8(Int) -> IntTruncate to unsigned 8-bit (0..255)
FunctionSignatureDescription
parse(String) -> Result[Int, String]Parse decimal string
from_hex(String) -> Result[Int, String]Parse hex string
FunctionSignatureDescription
abs(Int) -> IntAbsolute value
min(Int, Int) -> IntSmaller of two
max(Int, Int) -> IntLarger of two
clamp(Int, Int, Int) -> IntClamp to range [lo, hi]
FunctionSignatureDescription
band(Int, Int) -> IntBitwise AND
bor(Int, Int) -> IntBitwise OR
bxor(Int, Int) -> IntBitwise XOR
bnot(Int) -> IntBitwise NOT
bshl(Int, Int) -> IntShift left
bshr(Int, Int) -> IntShift right (arithmetic)
FunctionSignatureDescription
wrap_add(Int, Int, Int) -> IntWrapping add within bit width
wrap_mul(Int, Int, Int) -> IntWrapping multiply within bit width
rotate_right(Int, Int, Int) -> IntRotate bits right
rotate_left(Int, Int, Int) -> IntRotate bits left
int.to_string(42) // => "42"
int.parse("123") // => ok(123)
int.to_hex(255) // => "ff"
int.abs(-5) // => 5
int.clamp(15, 0, 10) // => 10
int.band(0b1100, 0b1010) // => 8 (0b1000)
int.wrap_add(255, 1, 8) // => 0