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