Get Started
Bits/Bytes
On this page
  1. Bitwise AND / OR / XOR
  2. Bitwise NOT
  3. Bit Shift / Rotate
  4. Toggle Bits
  5. Count True Bits
  6. Decompose to Bit List
  7. Decompose to Byte List
  8. Decompose to Word (2-byte) List
  9. Combine Bit List
  10. Combine Byte List
  11. Combine Word (2-byte) List
  12. Extract Bits
  13. Extract Bytes
  14. Reverse Bit Order
  15. Reverse Byte Order
  16. Reverse Word (2-byte) Order
  17. Set Bits
  18. Set Bytes
  19. Convert Decimal to BCD List
  20. Convert BCD List to Decimal

Bits/Bytes

Blocks that handle integers at the bit and byte level. Every input value is automatically converted to a 4-byte (32-bit) integer; bit and byte positions count from 0, and position 0 is the LSB (Least Significant Bit/Byte). In the lists produced by the decompose blocks and accepted by the combine blocks, the first item is the LSB; items of a bit list are [Digital] and items of a byte or word list are [Number]. Connect a Create List With block to a combine block to supply its items.

Caution The lists in this category are little-endian (the first item is the LSB), while the byte array and hexadecimal text conversions in the Type Conversion category are big-endian (the first byte is the MSB). The same value passed through the two categories comes out in the opposite byte order, so choose the blocks to match the byte order of the communication protocol.

Bitwise AND / OR / XOR

Bitwise AND / OR / XOR

Performs a bitwise AND, OR, or exclusive OR (XOR) on two input values. The input values are automatically converted to integers.

  • Input: value1 [Number], value2 [Number]
  • Output: calculated value [Number]

Bitwise NOT

Bitwise NOT

Inverts every bit of the input value (NOT). The input value is automatically converted to an integer.

  • Input: value [Number]
  • Output: calculated value [Number]

Bit Shift / Rotate

Bit Shift / Rotate

Shifts (shift) or rotates (rotate) the bits of the input value left or right by the specified number of bits. The input value is automatically converted to an integer.

  • Input: value [Number], number of bits to shift or rotate [Number]
  • Output: result value [Number]

Toggle Bits

Toggle Bits

Toggles n bits starting at the specified bit position (true ↔ false). The input value is automatically converted to a 4-byte (32-bit) integer; positions start at 0, and position 0 is the LSB.

  • Input: value [Number], start position [Number], count to toggle [Number]
  • Output: calculated value [Number]

Count True Bits

Count True Bits

Counts the bits that are true (1) in the input value. The input value is automatically converted to a 4-byte (32-bit) integer.

  • Input: value [Number]
  • Output: number of true bits [Number]

Decompose to Bit List

Decompose to Bit List

Decomposes the input value into a list of bits. The input value is automatically converted to a 4-byte (32-bit) integer, and the first item of the list is the LSB. Example: decimal 123 → binary 01111011 → [true, true, false, true, true, true, true, false]

  • Input: value [Number]
  • Output: decomposed bits [List]

Decompose to Byte List

Decompose to Byte List

Decomposes the input value into a list of bytes. The input value is automatically converted to a 4-byte integer, and the first item of the list is the LSB (Least Significant Byte).

  • Input: value [Number]
  • Output: decomposed bytes [List]

Decompose to Word (2-byte) List

Decompose to Word (2-byte) List

Decomposes the input value into a list of 2-byte words. The input value is automatically converted to a 4-byte integer, and the first item of the list is the least significant word.

  • Input: value [Number]
  • Output: decomposed words [List]

Combine Bit List

Combine Bit List

Combines a list of bits into a 4-byte (32-bit) integer. The first item of the list is the LSB. Example: [true, true, false, true, true, true, true, false] → binary 01111011 → decimal 123

  • Input: bit list [List]
  • Output: combined integer value [Number]

Combine Byte List

Combine Byte List

Combines a list of bytes into a 4-byte integer. The first item of the list is the LSB (Least Significant Byte).

  • Input: byte list [List]
  • Output: combined integer value [Number]

Combine Word (2-byte) List

Combine Word (2-byte) List

Combines a list of 2-byte words into a 4-byte integer. The first item of the list is the least significant word.

  • Input: word list [List]
  • Output: combined integer value [Number]

Extract Bits

Extract Bits

Extracts n bits starting at the specified bit position and returns them as a number. The input value is automatically converted to a 4-byte (32-bit) integer; positions start at 0, and position 0 is the LSB.

  • Input: value [Number], position [Number], count [Number]
  • Output: extracted value [Number]

Extract Bytes

Extract Bytes

Extracts n bytes starting at the specified byte position and returns them as a number. The input value is automatically converted to a 4-byte integer; positions start at 0, and position 0 is the LSB (Least Significant Byte).

  • Input: value [Number], position [Number], count [Number]
  • Output: extracted value [Number]

Reverse Bit Order

Reverse Bit Order

Reverses the order of the specified number of bits starting at the specified bit position. The input value is automatically converted to a 4-byte (32-bit) integer; positions start at 0, and position 0 is the LSB.

  • Input: value [Number], position [Number], count [Number]
  • Output: calculated value [Number]

Reverse Byte Order

Reverse Byte Order

Reverses the order of the specified number of bytes starting at the specified byte position. The input value is automatically converted to a 4-byte integer; positions start at 0, and position 0 is the LSB (Least Significant Byte).

  • Input: value [Number], position [Number], count [Number]
  • Output: calculated value [Number]

Reverse Word (2-byte) Order

Reverse Word (2-byte) Order

Swaps the high and low 2-byte words of the input value. The input value is automatically converted to a 4-byte integer.

  • Input: value [Number]
  • Output: calculated value [Number]

Set Bits

Set Bits

Sets n bits starting at the specified bit position to true or false. The input value is automatically converted to a 4-byte (32-bit) integer; positions start at 0, and position 0 is the LSB.

  • Input: value [Number], position [Number], count [Number], value [Digital]
  • Output: calculated value [Number]

Set Bytes

Set Bytes

Sets n bytes starting at the specified byte position to a value in the range 0-255. The input value is automatically converted to a 4-byte integer; positions start at 0, and position 0 is the LSB (Least Significant Byte).

  • Input: value [Number], position [Number], count [Number], value [Number]
  • Output: calculated value [Number]

Convert Decimal to BCD List

Convert Decimal to BCD List

Converts a decimal input value to a BCD (Binary Coded Decimal) list.

  • Input: value [Number]
  • Output: converted BCD list [List]

Convert BCD List to Decimal

Convert BCD List to Decimal

Converts a BCD list to a decimal number.

  • Input: BCD list [List]
  • Output: converted value [Number]