Light Dark

Functions

and

fn (a: Int | Byte, b: Int | Byte): Int | Byte

Bitwise AND of a and b.

Example

::hot::bit/and(12, 10)  // 8 (0b1100 & 0b1010 = 0b1000)

not

fn (a: Int | Byte): Int | Byte

Bitwise NOT (ones' complement) of a.

Example

::hot::bit/not(0)  // -1 (all bits set for Int)

or

fn (a: Int | Byte, b: Int | Byte): Int | Byte

Bitwise OR of a and b.

Example

::hot::bit/or(12, 10)  // 14 (0b1100 | 0b1010 = 0b1110)

shift-left

fn (a: Int | Byte, n: Int): Int | Byte

Shift a left by n bits.

Example

::hot::bit/shift-left(1, 4)   // 16 (1 << 4)
::hot::bit/shift-left(3, 2)   // 12 (3 << 2)

shift-right

fn (a: Int | Byte, n: Int): Int | Byte

Shift a right by n bits. For signed integers, this is an arithmetic shift (preserves sign).

Example

::hot::bit/shift-right(16, 2)   // 4 (16 >> 2)
::hot::bit/shift-right(-8, 1)   // -4 (arithmetic shift preserves sign)

xor

fn (a: Int | Byte, b: Int | Byte): Int | Byte

Bitwise XOR (exclusive or) of a and b.

Example

::hot::bit/xor(12, 10)  // 6 (0b1100 ^ 0b1010 = 0b0110)