- Documentation
- Shared functions
- bitExtract
Function
bitExtract
Extracts count bits starting at position start (0 is the lowest bit). The position and length must fit in 32 bits.
Syntax
int bitExtract(int value, int start [, int count = 1])Arguments
valueint- The number.
startint- Position of the first bit.
countint, optional = 1- Number of bits.
Returns
The extracted bits or false.
Example
local packed = 0x00ABCDEF
print(string.format("%X", bitExtract(packed, 8, 8))) -- CD