I prefer looping over the number of bits and doing a check along the lines of
If that is true, then bit curbit is set (the least significant bit being bit 0). This is very similar to what weaknessforcats said, except that one is
:D
Code:
if ( num & (1 << curbit) )
Code:
if ( (num >> curbit) & 1 )
Comment