Nat16

16-bit unsigned integers with checked arithmetic

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

toNat

Conversion.

let toNat : (Nat16) -> Nat

fromNat

Conversion. Traps on overflow/underflow.

let fromNat : (Nat) -> Nat16

toText

Returns the Text representation of x.

func toText(x : Nat16) : Text

min

Returns the minimum of x and y.

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

max

Returns the maximum of x and y.

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

equal

Returns x == y.

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

notEqual

Returns x != y.

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

less

Returns x < y.

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

lessOrEqual

Returns x ⇐ y.

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

greater

Returns x > y.

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

greaterOrEqual

Returns x >= y.

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

compare

Returns the order of x and y.

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

add

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

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

sub

Returns the difference of x and y, x - y. Traps on underflow.

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

mul

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

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

div

Returns the division of x by y, x / y. Traps on division by zero.

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

rem

Returns the remainder of x divided by y, x % y.

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

pow

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

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