Int16

16-bit signed integers with checked arithmetic

Most operations are available as built-in operators (e.g. 1 + 1).

Int16

type Int16 = Prim.Types.Int16

16-bit signed integers

toInt

let toInt : Int16 -> Int

Conversion.

fromInt

let fromInt : Int -> Int16

Conversion. Traps on overflow/underflow.

fromIntWrap

let fromIntWrap : Int -> Int16

Conversion. Wraps on overflow/underflow.

fromNat16

let fromNat16 : Nat16 -> Int16

Conversion. Wraps on overflow/underflow.

toNat16

let toNat16 : Int16 -> Nat16

Conversion. Wraps on overflow/underflow.

toText

func toText(x : Int16) : Text

Returns the Text representation of x.

abs

func abs(x : Int16) : Int16

Returns the absolute value of x. Traps when x = -2^15.

min

func min(x : Int16, y : Int16) : Int16

Returns the minimum of x and y.

max

func max(x : Int16, y : Int16) : Int16

Returns the maximum of x and y.

equal

func equal(x : Int16, y : Int16) : Bool

Returns x == y.

notEqual

func notEqual(x : Int16, y : Int16) : Bool

Returns x != y.

less

func less(x : Int16, y : Int16) : Bool

Returns x < y.

lessOrEqual

func lessOrEqual(x : Int16, y : Int16) : Bool

Returns x ⇐ y.

greater

func greater(x : Int16, y : Int16) : Bool

Returns x > y.

greaterOrEqual

func greaterOrEqual(x : Int16, y : Int16) : Bool

Returns x >= y.

compare

func compare(x : Int16, y : Int16) : {#less; #equal; #greater}

Returns the order of x and y.

neg

func neg(x : Int16) : Int16

Returns the negation of x, -x. Traps on overflow.

add

func add(x : Int16, y : Int16) : Int16

Returns the sum of x and y, x + y. Traps on overflow.

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.

pow

func pow(x : Int16, y : Int16) : Int16

Returns x to the power of y, x ** y. Traps on overflow.

bitnot

func bitnot(x : Int16, y : Int16) : Int16

Returns the bitwise negation of x, ^x.

bitand

func bitand(x : Int16, y : Int16) : Int16

Returns the bitwise and of x and y, x & y.

bitor

func bitor(x : Int16, y : Int16) : Int16

Returns the bitwise or of x and y, x \| y.

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).

bitset

func bitset(x : Int16, p : Nat) : Int16

Returns the value of setting bit p mod 16 in x to 1.

bitclear

func bitclear(x : Int16, p : Nat) : Int16

Returns the value of clearing bit p mod 16 in x to 0.

bitflip

func bitflip(x : Int16, p : Nat) : Int16

Returns the value of flipping bit p mod 16 in x.

bitcountNonZero

let bitcountNonZero : (x : Int16) -> Int16

Returns the count of non-zero bits in x.

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.

mulWrap

func mulWrap(x : Int16, y : Int16) : Int16

Returns the product of x and y, x *% y. Wraps on overflow.

powWrap

func powWrap(x : Int16, y : Int16) : Int16

Returns x to the power of y, x **% y. Wraps on overflow. Traps if y < 0.