Can anyone suggest any bit tricks that will get me beyond 0 to 15 for a single byte that represents 2 distinct variables? I'd like to extend beyond 16 nodeIDs.
A byte can store a value from 0 to 255. That's 8 bits. You can also store 2 values from 0-15 (2 4 bit numbers). You can't store more than that.
It looks like your code is trying to pack 2 4-bit (0-15) values into 1 byte, which is valid.
If you want to store more than 16 possible values in a byte, don't pack multiple things into the byte. Simply use all possible values from 0-255, and save your pNum value in a different byte.
danoduino:
Can anyone suggest any bit tricks that will get me beyond 0 to 15 for a single byte that represents 2 distinct variables? I'd like to extend beyond 16 nodeIDs.