MT UnPack Bits
- Updated2023-02-17
- 4 minute(s) read
MT UnPack Bits
Unpacks data to an unsigned or signed integer array.
This node unpacks 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 integers
The signed or unsigned integer data an, n = 0…N-1, to be converted into binary data.
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

output bit stream
The output binary data stream bi = {0,1}, i = 0…MN-1, that corresponds to the packed representation of the input binary data.
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.

error out
Error information.
The node produces this output according to standard error behavior.
Relationship between Input Integers and Output Bit Stream
The relationship between the input integers and the output bit stream is given by the following equations:
b i×M+j = (ai»(M-1-j)) &1, j = 0…M-1, i = 0…N - 1 (packed bit order set to MSB first)
b i×M+j = (ai»j) &1, j = 0…M - 1, i = 0…N - 1 (packed bit order set to LSB first)
Where » denotes the operation of right shifting, and the operator & stands for the logical AND operation.
For example, assume the input integers array is the element [4], the bits per integer value is specified as 3, and integer format is set to Unsigned. If packed bit order is set to MSB first, the output bit stream is [1 0 0]. If the packed bit order is set to LSB first, the output bit stream is [0 0 1]. The signed negative numbers are stored as the 2's complement. Thus, if integer format is set to Signed and the bits per integer is set to 3, the input integer array is the element [-3], and the packed bit order is set to MSB First the output bit stream is [1 0 1].