Three questions that I seem to be stuck on:
-
Why is the code
x & ~077better than this line of codex & 0177700.
Would it be because there is less loss of precision? -
Why is this code incorrect for setting bit 5 in a number?
num = num + 0x20
Would it be because we need to use logical or,|, not the+? -
Why is this code
x & 0xFFbetter than this line of code(x << 24) >> 24?
The right expression could result in sign extension which changes the original int. I am sure that is correct from examples I have done.
Because in the second one you are making assumptions on the length of the integer type of x
yes! they are different operators.