Word32

32-bit binary unsigned integers with modular arithmetic

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

toNat

Conversion.

let toNat : (Word32) -> Nat

fromNat

Conversion. Wraps around.

let fromNat : (Nat) -> Word32

toInt

Conversion. Returns x mod 2^32.

let toInt : (Word32) -> Int

fromInt

Conversion. Returns x mod 2^32.

let fromInt : (Int) -> Word32

toText

Returns the Text representation of x.

func toText(x : Word32) : Text

min

Returns the minimum of x and y.

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

max

Returns the maximum of x and y.

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

equal

Returns x == y.

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

notEqual

Returns x != y.

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

less

Returns x < y.

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

lessOrEqual

Returns x ⇐ y.

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

greater

Returns x > y.

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

greaterOrEqual

Returns x >= y.

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

compare

Returns the order of x and y.

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

add

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

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

sub

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

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

mul

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

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

div

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

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

rem

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

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

pow

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

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

bitnot

Returns the bitwise negation of x, ^x.

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

bitand

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

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

bitor

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

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

bitxor

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

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

bitshiftLeft

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

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

bitshiftRight

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

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

bitshiftRightSigned

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

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

bitrotLeft

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

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

bitrotRight

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

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

popcnt

Returns the count of non-zero bits in x.

let popcnt : (Word32) -> Word32

clz

Returns the count of leading zero bits in x.

let clz : (Word32) -> Word32

ctz

Returns the count of trailing zero bits in x.

let ctz : (Word32) -> Word32

btst

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

let btst : (Word32, Word32) -> Bool