Core utility functions for integer arithmetic - absolute value, min/max, clamping, bit manipulation, and checked/saturating/wrapping operations.
All functions are backed by the Rust runtime.
Absolute value of x.
Larger of a and b.
Smaller of a and b.
Clamps value to the range [low, high].
Number of ones in the binary representation of x (popcount).
Number of leading zeros in the binary representation of x.
Number of trailing zeros in the binary representation of x.
Reverses the byte order of x.
Rotates the bits of x left by n positions.
Rotates the bits of x right by n positions.
a + b, returns 0 on overflow.
a - b, returns 0 on underflow.
a * b, returns 0 on overflow.
a / b, returns 0 on division by zero.
a + b, saturates at Int min/max.
a - b, saturates at Int min/max.
a + b, wraps on overflow.
a - b, wraps on underflow.
a * b, wraps on overflow.
load std.core
let a = core.abs(-5) # 5
let m = core.max(3, 7) # 7
let c = core.clamp(15, 0, 10) # 10
let n = core.count_ones(42) # 3
let sa = core.saturating_add(9223372036854775807, 1)
let wa = core.wrapping_add(255, 1)