Int8
8-bit signed integers with checked arithmetic
Most operations are available as built-in operators (e.g. 1 + 1
).
sub
func sub(x : Int8, y : Int8) : Int8
Returns the difference of x
and y
, x - y
. Traps on underflow.
div
func div(x : Int8, y : Int8) : Int8
Returns the division of x by y
, x / y
.
Traps when y
is zero.
rem
func rem(x : Int8, y : Int8) : Int8
Returns the remainder of x
divided by y
, x % y
.
Traps when y
is zero.
bitshiftLeft
func bitshiftLeft(x : Int8, y : Int8) : Int8
Returns the bitwise shift left of x
by y
, x << y
.
bitshiftRight
func bitshiftRight(x : Int8, y : Int8) : Int8
Returns the bitwise shift right of x
by y
, x >> y
.
bitrotLeft
func bitrotLeft(x : Int8, y : Int8) : Int8
Returns the bitwise rotate left of x
by y
, x <<> y
.
bitrotRight
func bitrotRight(x : Int8, y : Int8) : Int8
Returns the bitwise rotate right of x
by y
, x <>> y
.
bittest
func bittest(x : Int8, p : Nat) : Bool
Returns the value of bit p mod 8
in x
, (x & 2^(p mod 8)) == 2^(p mod 8)
.
bitclear
func bitclear(x : Int8, p : Nat) : Int8
Returns the value of clearing bit p mod 8
in x
to 0
.
bitcountLeadingZero
let bitcountLeadingZero : (x : Int8) -> Int8
Returns the count of leading zero bits in x
.
bitcountTrailingZero
let bitcountTrailingZero : (x : Int8) -> Int8
Returns the count of trailing zero bits in x
.
addWrap
func addWrap(x : Int8, y : Int8) : Int8
Returns the sum of x
and y
, x +% y
. Wraps on overflow.
subWrap
func subWrap(x : Int8, y : Int8) : Int8
Returns the difference of x
and y
, x -% y
. Wraps on underflow.