Int
to_string
Section titled “to_string”fn to_string(n: Int) -> StringDecimal digits, with - if negative.
fn parse(s: String) -> Int fails ParseErrorReads decimal digits, with an optional leading - or +: Int.parse("-42") is -42.
Fails with ParseError if anything else is in s (including spaces), or if the value is outside
the range of Int.
checked_add
Section titled “checked_add”fn checked_add(a: Int, b: Int) -> Option[Int]None on overflow.
bit_and
Section titled “bit_and”fn bit_and(a: Int, b: Int) -> IntReads as flags.bit_and(MASK).
bit_or
Section titled “bit_or”fn bit_or(a: Int, b: Int) -> IntBitwise OR.
bit_xor
Section titled “bit_xor”fn bit_xor(a: Int, b: Int) -> IntBitwise exclusive OR.
bit_not
Section titled “bit_not”fn bit_not(n: Int) -> IntSame as -n - 1.
shift_left
Section titled “shift_left”fn shift_left(n: Int, by: Int) -> Int0 if by is 32 or more; a defect if by is negative.
shift_right
Section titled “shift_right”fn shift_right(n: Int, by: Int) -> IntArithmetic shift: fills the high bits with the sign.
0 or -1 if by is 32 or more; a defect if by is negative.
shift_right_unsigned
Section titled “shift_right_unsigned”fn shift_right_unsigned(n: Int, by: Int) -> IntLogical shift: fills the high bits with 0. 0 if by is 32 or more; a defect if by is
negative.
fn max(a: Int, b: Int) -> IntReturns the larger value, or a when equal.
fn min(a: Int, b: Int) -> IntReturns the smaller value, or a when equal.
fn abs(n: Int) -> IntAbsolute value. The minimum Int wraps back to itself, like integer negation.