Skip to main content

Bits

FunctionDescriptionMeta
bits.and

z := bits.and(x, y)

Returns the bitwise "AND" of two integers.

Arguments:
x (number)

the first integer

y (number)

the second integer

Returns:
z (number)

the bitwise AND of x and y

v0.18.0 Wasm
bits.lsh

z := bits.lsh(x, s)

Returns a new integer with its bits shifted s bits to the left.

Arguments:
x (number)

the integer to shift

s (number)

the number of bits to shift

Returns:
z (number)

the result of shifting x s bits to the left

v0.18.0 Wasm
bits.negate

z := bits.negate(x)

Returns the bitwise negation (flip) of an integer.

Arguments:
x (number)

the integer to negate

Returns:
z (number)

the bitwise negation of x

v0.18.0 Wasm
bits.or

z := bits.or(x, y)

Returns the bitwise "OR" of two integers.

Arguments:
x (number)

the first integer

y (number)

the second integer

Returns:
z (number)

the bitwise OR of x and y

v0.18.0 Wasm
bits.rsh

z := bits.rsh(x, s)

Returns a new integer with its bits shifted s bits to the right.

Arguments:
x (number)

the integer to shift

s (number)

the number of bits to shift

Returns:
z (number)

the result of shifting x s bits to the right

v0.18.0 Wasm
bits.xor

z := bits.xor(x, y)

Returns the bitwise "XOR" (exclusive-or) of two integers.

Arguments:
x (number)

the first integer

y (number)

the second integer

Returns:
z (number)

the bitwise XOR of x and y

v0.18.0 Wasm