Complete the code to double the value using bit manipulation.
int result = number [1] 1;
Left shifting by 1 bit multiplies the number by 2.
Complete the code to check if a number is even using bit manipulation.
boolean isEven = (number [1] 1) == 0;
Bitwise AND with 1 checks the least significant bit; if 0, number is even.
Fix the error in the code to divide a number by 4 using bit manipulation.
int result = number [1] 2;
Right shifting by 2 bits divides the number by 4.
Fill both blanks to toggle the 3rd bit of a number.
int mask = 1 [1] 2; int result = number [2] mask;
Shift 1 left by 2 to create mask for 3rd bit, then XOR toggles that bit.
Fill all three blanks to set the 5th bit and clear the 2nd bit of a number.
int setMask = 1 [1] 4; int clearMask = ~(1 [2] 1); int result = (number [3] setMask) & clearMask;
Shift 1 left by 4 for 5th bit mask, shift 1 left by 1 for 2nd bit mask, OR to set bit, AND with negated mask to clear bit.
