Std.Int
Integer conversion, arithmetic, and bitwise operations.
Functions
to_float
fun to_float : Int -> FloatConverts an integer to a float.
parse
fun parse : (s: String) -> Maybe IntParses a string as an integer. Returns Nothing if the string is not a valid integer.
add
fun add : Int -> Int -> IntAdds two integers.
sub
fun sub : Int -> Int -> IntSubtracts the second integer from the first.
mul
fun mul : Int -> Int -> IntMultiplies two integers.
div
fun div : Int -> Int -> IntInteger division, truncating towards zero.
mod
fun mod : Int -> Int -> IntReturns the remainder of integer division.
abs
fun abs : Int -> IntReturns the absolute value.
min
fun min : Int -> Int -> IntReturns the smaller of two integers.
max
fun max : Int -> Int -> IntReturns the larger of two integers.
clamp
fun clamp : Int -> Int -> Int -> IntClamps a value to the range [low, high].
sign
fun sign : Int -> IntReturns -1 for negative, 0 for zero, 1 for positive.
band
fun band : (a: Int) -> (b: Int) -> IntBitwise AND.
bor
fun bor : (a: Int) -> (b: Int) -> IntBitwise OR.
bxor
fun bxor : (a: Int) -> (b: Int) -> IntBitwise XOR.
bnot
fun bnot : (n: Int) -> IntBitwise NOT (ones' complement).
shift_left
fun shift_left : (bits: Int) -> (n: Int) -> IntBitwise shift left.
shift_right
fun shift_right : (bits: Int) -> (n: Int) -> IntBitwise shift right.
to_hex
fun to_hex : Int -> StringConverts an integer into its equivalent lowercase hex string. Negative numbers are prefixed with "-".
parse_hex
fun parse_hex : String -> Maybe IntParses a hex string (with optional "-" prefix) as an integer. Accepts both upper and lower case digits. Returns Nothing if invalid.