Word16

16-bit binary unsigned integers with modular arithmetic

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

toNat

Conversion.

let toNat : (Word16) -> Nat

fromNat

Conversion. Wraps around.

let fromNat : (Nat) -> Word16

toInt

Conversion. Returns x mod 2^16.

let toInt : (Word16) -> Int

fromInt

Conversion. Returns x mod 2^16.

let fromInt : (Int) -> Word16

toText

Returns the Text representation of x.

func toText(x : Word16) : Text

min

Returns the minimum of x and y.

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

max

Returns the maximum of x and y.

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

equal

Returns x == y.

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

notEqual

Returns x != y.

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

less

Returns x < y.

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

lessOrEqual

Returns x ⇐ y.

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

greater

Returns x > y.

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

greaterOrEqual

Returns x >= y.

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

compare

Returns the order of x and y.

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

add

Returns the sum of x and y, (x + y) mod 2^16.

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

sub

Returns the difference of x and y, (2^16 + x - y) mod 2^16.

func sub(x : Word16, y : Word16) : Word16

mul

Returns the product of x and y, (x * y) mod 2^16.

func mul(x : Word16, y : Word16) : Word16

div

Returns the truncated quotient of x and y, floor (x / y). Traps when y is 0.

func div(x : Word16, y : Word16) : Word16

rem

Returns the remainder of the division of 'x' by y, x - y * floor ( x / y). Traps when y is 0.

func rem(x : Word16, y : Word16) : Word16

pow

Returns x to the power of y, (x ** y) mod 2^16.

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

bitnot

Returns the bitwise negation of x, ^x.

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

bitand

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

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

bitor

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

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

bitxor

Returns the bitwise exclusive or of x and y, x ^ y.

func bitxor(x : Word16, y : Word16) : Word16

bitshiftLeft

Returns the bitwise shift left of x by y, x << y.

func bitshiftLeft(x : Word16, y : Word16) : Word16

bitshiftRight

Returns the bitwise shift right of x by y, x >> y.

func bitshiftRight(x : Word16, y : Word16) : Word16

bitshiftRightSigned

Returns the signed shift right of x by y, x +>> y.

func bitshiftRightSigned(x : Word16, y : Word16) : Word16

bitrotLeft

Returns the bitwise rotate left of x by y, x <<> y.

func bitrotLeft(x : Word16, y : Word16) : Word16

bitrotRight

Returns the bitwise rotate right of x by y, x <>> y.

func bitrotRight(x : Word16, y : Word16) : Word16

popcnt

Returns the count of non-zero bits in x.

let popcnt : (Word16) -> Word16

clz

Returns the count of leading zero bits in x.

let clz : (Word16) -> Word16

ctz

Returns the count of trailing zero bits in x.

let ctz : (Word16) -> Word16

btst

Returns the result of testing bit y in x, (x & 2^y) == 2^y.

let btst : (Word16, Word16) -> Bool