Hey all,
First of all, I want to know if this is possible: let's say I have an unsigned long which contains some abritrary unsigned shorts, which may or may not be in the number. For example:
unsigned short int id1 = 3456,
id2 = 30998;
unsigned long long bitfld = id1|id2;
Can the other 2 fields be assumed as 0? And is OR the right operation for this? After that let's say I pass bitfld as an argument:
void dostuff (unsigned long long bf)
{
//pseudo code
if( the first field exists in bf)
get first field;
if( the second field exists in bf)
get second field;
//etc...
}
I think I have to poll out the first 16 bits of the bitfield and check those, then recursively poll them, verify them and store them if they are greater than 0. But I'm not sure how to do this, bit shifting only shifts left or right, thus, it only divides or multiplies right?