- Joined
- Jul 10, 2007
- Messages
- 6,306
Code:
//works?? don't know
bool getBit(byte bits, int index) { return 1 == (bits & intToByte(1 << index)); }
//does not work
void setBit(byte bits, int index, bool value) {
if (value) {
bits = bits | intToByte(1 << index);
}
else {
bits = bits & ~intToByte(1 << index);
}
}
from http://stackoverflow.com/questions/4674006/set-specific-bit-in-byte