MT Pack Bits
- Updated2023-02-17
- 4 minute(s) read
MT Pack Bits
Packs data to an unsigned or signed integer array.
This node packs MN-sized binary data of the form bi = {0,1}, to an unsigned or signed integer array a_n,
where
- i = 0…MN-1, and M denotes the number of bits per integer
- n = 0…N-1, and N denotes the size of the array
Inputs/Outputs

input bit stream
The binary bit stream to be packed into integers.
The binary bit stream must be in the form bi = {0,1}
where
- i = 0…MN-1, and M denotes the number of bits per integer
- n = 0…N-1, and N denotes the size of the array
Default value: empty

bits per integer
Number of binary data values that are packed into an integer.
If you set the integer format parameter to Unsigned, the maximum value is 31. If you set the integer format parameter to Signed, the maximum value is 32.
Default value: 1

packed bit order
The order in which the binary data stream is packed into integers.
| MSB first |
Data is packed with the most significant bit (MSB) first. |
| LSB first |
Data is packed with the least significant bit (LSB) first. |
Default value: MSB first

integer format
Input integer format.
| Unsigned |
The entire number is packed as a positive integer. |
| Signed |
The most significant bit (MSB) determines the sign of the input integer. |
Default value: Unsigned

error in
Error conditions that occur before this node runs.
The node responds to this input according to standard error behavior.
Default value: No error

reset ?
A Boolean that determines how the node handles buffered data. When the length of the input bit stream is not a multiple of the bits per integer value, the leftover bits are buffered inside the node. When you set reset? to FALSE, these buffered bits are prepended to the input bit stream during the next iteration.
Default value: TRUE

output integers
The output integer stream ann = 0…N-1, corresponding to the packed bits.

error out
Error information.
The node produces this output according to standard error behavior.
Relationship between Output Integers and Input Bit Stream
The relationship between the output integers array and the input bit stream for the unsigned integer format is given by the following equations:
If you set the integer format to Signed, then the MSB at the bit position N-1 is used to determine the sign of the output integer. The sign is positive if MSB is 0 and negative if MSB is 1. For example, if you set the integer format to Unsigned and bits per integer as 3, and packed bit order as MSB first, the bits [1 0 0] are mapped to the integer 4. If packed bit order is specified as LSB first, the bits are mapped to the integer 1. If the integer format is set to Signed and packed bit order is MSB first, the bits [1 0 0 ] are packed to integer -4 because the MSB is 1 in this case. If packed bit order is set to LSB first, the bits are mapped to integer 1, because MSB is 0 in this case.