int extractBit(char byte, unsigned int pos)
{
assert(pos < 8);
return ((byte >> pos) & 1);
}
Extract a range of bits from a character.
char extractBitRange(char byte, unsigned int startPos, unsigned int offset)
{
assert((startPos + offset) < 8);
return (byte >> startPos) & ~(0xfe << offset);
}
No comments:
Post a Comment