Bitwise

Usine provides a full set of modules for working on values bit by bit. They cover boolean logic, shifting and rotating, unsigned 32-bit integer arithmetic (with wrap-around), single-value bit inspection and manipulation, a bitwise counter, and conversions to and from integers, strings and bit-arrays.

All bitwise flows use hexadecimal values (0-9, A-F), for example $FA234B or $FFFF.

Bitwise flows are not directly compatible with data flows. You must use integer-to-bitwise to set bitwise inlets and bitwise-to-integer to retrieve outlet values. Bitwise inputs are in hexadecimal format (0123456789ABCDEF). ie. $FA234B, $FFFF, etc. Bitwise flows are compatible with Color flows.

Logic

Boolean operators applied to every bit of the operands.

Module Description
Bitwise AND A AND B
Bitwise OR A OR B
Bitwise XOR A XOR B
Bitwise NOT NOT A (inversion)
Bitwise NAND NOT (A AND B) — universal gate
Bitwise NOR NOT (A OR B) — universal gate
Bitwise XNOR NOT (A XOR B) — bit equality

Shift and rotate

Move bits left or right. Shifts fill with zeros; rotations wrap the bits around.

Module Description
Bitwise SHL Shift left (fills with zeros)
Bitwise SHR Shift right (fills with zeros)
Bitwise ROL Rotate left (bits wrap around)
Bitwise ROR Rotate right (bits wrap around)

Arithmetic

Unsigned 32-bit integer arithmetic. Results wrap around on overflow instead of switching to floating-point.

Module Description
Bitwise ADD A + B
Bitwise SUB A - B
Bitwise MULT A * B (low 32 bits)
Bitwise DIV A / B integer (0 if B = 0)
Bitwise MOD A mod B (0 if B = 0)
Bitwise Counter 32-bit up/down counter with min/max modes

Bit inspection and manipulation

Read, count, locate, set or rearrange individual bits of a value.

Module Description
Bitwise Count Number of bits set to 1 (population count)
Bitwise MSB Position of the highest set bit (-1 if 0)
Bitwise LSB Position of the lowest set bit (-1 if 0)
Bitwise Get Read a single bit (0/1) at a given index
Bitwise Set Set or clear a single bit at a given index
Bitwise Mask Generate a mask of n low-order bits
Bitwise Field Extract a bit field (offset, width)
Bitwise Reverse Reverse the order of all 32 bits
Bitwise Swap Swap byte order (endianness)
Bitwise Gray Binary to reflected Gray code
Bitwise un-Gray Reflected Gray code back to binary
Bitwise CRC32 CRC32 checksum

Constant and conversions

Emit a fixed value, or convert between bitwise and other data types.

Module Description
Bitwise Constant Constant bitwise value
Bitwise Integer to Bitwise Integer to bitwise conversion
Bitwise to Integer Bitwise to integer conversion
Bitwise String to Bitwise Binary string to bitwise conversion
Bitwise to String Bitwise to binary/hex string conversion
Bitwise Bit Array to Bitwise 0/1 array to bitwise conversion
Bitwise to Bit Array Bitwise to 0/1 array conversion

See also

version 7.0.250121

Edit All Pages