I am using an unsigned long long to do bit manipulation. When trying to tell if bits are set or not, my code detects that bit 32 is set even when it is not. Here is my code, the if statement is where the problem is.
Code:
void recover(unsigned int branch_id)
{
unsigned long long mask = gbm.get_younger_branches(branch_id);
/* mask prints as: 0x7 here */
printf("0x%llX\n", mask);
for (int i = 0; i < entries.size(); ++i)
{
for (int j = 0; j < sizeof(unsigned long long) * 8; ++j)
{
/* this gets entered for j = 0, 1, 2, 32 */
if (mask & (1 << j))
{
entries[i]->release_branch_id(j);
}
}
}
}
Thanks.