- 1. What is the result of the bitwise NOT operation on the binary value 0111 (decimal 7)?
A) 1111 (decimal 15) B) 0110 (decimal 6) C) 1000 (decimal 8) D) 0001 (decimal 1)
- 2. Which bitwise operation is used to determine whether a particular bit is set or cleared?
A) NOT B) OR C) XOR D) AND
- 3. What is the result of the bitwise AND operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0001 (decimal 1) B) 0011 (decimal 3) C) 0100 (decimal 4) D) 0111 (decimal 7)
- 4. How can you determine if a number is even using bitwise operations?
A) Check if the highest valued bit is 1 using OR with 1000 (decimal 8) B) Check if the lowest valued bit is 1 using XOR with 0001 (decimal 1) C) Check if the lowest valued bit is 0 using AND with 0001 (decimal 1) D) Check if the highest valued bit is 0 using NOT
- 5. What is the result of the bitwise OR operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0100 (decimal 4) B) 0010 (decimal 2) C) 1000 (decimal 8) D) 0111 (decimal 7)
- 6. What is the result of the bitwise XOR operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0111 (decimal 7) B) 0101 (decimal 5) C) 0110 (decimal 6) D) 0000 (decimal 0)
- 7. Which bitwise operation can be used to toggle bits in a register?
A) AND B) XOR C) NOT D) OR
- 8. What is the result of the bitwise AND operation between 0110 (decimal 6) and 1011 (decimal 11)?
A) 0010 (decimal 2) B) 0000 (decimal 0) C) 0101 (decimal 5) D) 1111 (decimal 15)
- 9. How can you set the fourth bit of 0010 (decimal 2) using bitwise operations?
A) Perform a bitwise XOR with 1000 (decimal 8) B) Perform a bitwise NOT with 1000 (decimal 8) C) Perform a bitwise AND with 1000 (decimal 8) D) Perform a bitwise OR with 1000 (decimal 8)
- 10. Which bitwise operation is often used to invert a grayscale image?
A) XOR B) OR C) NOT D) AND
- 11. What is the result of the bitwise OR operation between 0010 (decimal 2) and 1000 (decimal 8)?
A) 1000 (decimal 8) B) 0010 (decimal 2) C) 1011 (decimal 11) D) 1010 (decimal 10)
- 12. What is the result of the bitwise NOT operation on 10101011 (decimal 171)?
A) 10101010 (decimal 170) B) 11111111 (decimal 255) C) 01010100 (decimal 84) D) 01010101 (decimal 85)
- 13. How can you set a register to zero using XOR?
A) Perform XOR on the register with itself B) Perform NOT on the register C) Perform AND on the register with zero D) Perform OR on the register with zero
- 14. What is the mathematical equivalent of the bitwise NOT operation for a non-negative integer x?
A) x AND y B) x OR y C) (2floor(log2(x) + 1) - 1) - x D) x XOR y
- 15. Which bitwise operation is used to set selected bits to 1?
A) NOT B) OR C) AND D) XOR
- 16. What is the result of the bitwise XOR operation between 0101 (decimal 5) and 0101 (decimal 5)?
A) 1010 (decimal 10) B) 0000 (decimal 0) C) 0101 (decimal 5) D) 1111 (decimal 15)
- 17. What is the result of the bitwise OR operation between 0101 (decimal 5) and 0101 (decimal 5)?
A) 1010 (decimal 10) B) 1111 (decimal 15) C) 0000 (decimal 0) D) 0101 (decimal 5)
- 18. How many possible truth functions are there for two binary variables?
A) 32 B) 16 C) 8 D) 4
- 19. What is the term used for a lookup table with two inputs in Boolean functions?
A) LUT1 B) LUT4 C) LUT3 D) LUT2
- 20. What term is used for instructions with a 4-bit field identifying a specific binary connective?
A) Connective B) Opcode C) Bitwise operation D) Boolean operation
- 21. How many operations are there in a bitwise ternary logic instruction?
A) 64 B) 128 C) 256 D) 16
- 22. What orientation is used when a left shift increases the value of a number?
A) Middle-endian B) Big-endian C) Small-endian D) Little-endian
- 23. What is the effect of multiple shifts shortened to a single shift by some number of digits?
A) Equivalent to shifting by half that number of digits B) Equivalent to shifting by double that number of digits C) Equivalent to shifting by that number of digits D) No effect
- 24. What is the term for the values of the shifted-in bits in bit shift operations?
A) Shifted-in bits B) Carry bits C) Shifted-out bits D) Sign bits
- 25. What is the dominant representation in the current marketplace for arithmetic shifts?
A) Ones' complement B) Two's complement C) Floating point D) Sign magnitude
- 26. What happens to the bits that are shifted out of either end in an arithmetic shift?
A) They are preserved B) They are inverted C) They are discarded D) They are copied
- 27. Which type of shift is ideal for unsigned binary numbers?
A) Arithmetic right-shift B) Logical right-shift C) Rotate through carry D) Circular shift
- 28. What operation is used to retain all existing bits by rotating them?
A) Circular shift B) Bitwise AND C) Arithmetic shift D) Logical shift
- 29. In C and C++, what is the operator for a left shift?
A) & B) | C) >> D) <<
- 30. What is the behavior of shifting by a bit count greater than or equal to the word's size in C and C++?
A) Logical shift B) Undefined behavior C) Circular shift D) Arithmetic shift
- 31. In C#, what type of shift is performed when the first operand is an int or long?
A) Arithmetic shift B) Circular shift C) Logical shift D) Rotate through carry
- 32. In C#, what type of shift is performed when the first operand is of type uint or ulong?
A) Circular shift B) Arithmetic shift C) Logical shift D) Rotate through carry
- 33. What is the behavior of right-shifting a negative value in C and C++?
A) Logical shift B) Implementation-defined C) Arithmetic shift D) Circular shift
- 34. What is the operator for a right shift in C and C++?
A) << B) | C) >> D) &
- 35. What is the result of x RIGHT-ROTATE-THROUGH-CARRY-BY-ONE if the carry flag contains a copy of the sign bit?
A) An arithmetic right-shift B) A logical right-shift C) A circular shift D) A bitwise AND
- 36. Which C++ version introduced std::rotl and std::rotr for rotate operations?
A) C++14 B) C++20 C) C++17 D) C++11
- 37. What is the recommended way to avoid undefined behavior and branches in GCC and Clang for circular shifts?
A) Use multiple machine instructions B) Use arithmetic shifts C) Use a recognized pattern for a single rotate instruction D) Use a branch to check shift amount
- 38. Which compiler provides intrinsics like _rotl8, _rotl16, _rotr8, _rotr16?
A) Clang B) Intel C) Microsoft Visual C++ D) GCC
- 39. In Java, which operator performs logical right shifts?
A) << B) >> C) >>> D) <<<
- 40. What is the result of the expression 'byte b1 = -5; int i = b1 | 0x0200;' in Java?
A) i == 517 B) i == 2049 C) i == 0 D) i == -5
- 41. What is the mask value used for the right-hand operand in Java when the left-hand operand is of type int?
A) 0x0 (0b00000000) B) 0xff (0b11111111) C) 0x3f (0b111111) D) 0x1f (0b11111)
- 42. Which of the following is a compiler-specific intrinsic for circular shifts in Microsoft Visual C++?
A) __builtin_stdc_rotate_left B) __builtin_stdc_rotate_right C) _rotl16 D) std::rotl
- 43. What is the recommended way to perform circular shifts in high-integrity software?
A) Use arithmetic shifts B) Use multiple machine instructions C) Use branches to check shift amount D) Use compiler-recognized patterns for single rotate instructions
- 44. Which of the following is a compiler-specific intrinsic for circular shifts in GCC 15?
A) __builtin_stdc_rotate_right B) _rotl16 C) __builtin_stdc_rotate_left D) std::rotl
- 45. What is the mask value used for the right-hand operand in Java when the left-hand operand is of type long?
A) 0x0 (0b00000000) B) 0x1f (0b11111) C) 0x3f (0b111111) D) 0xff (0b11111111)
- 46. Which operation is used in cryptography to count the number of 1s in a binary number?
A) count leading zeros B) bitwise OR C) popcount D) bitwise AND
- 47. Which programming domain often requires bitwise operations?
A) User interface design B) Database management C) Device drivers D) Web development
- 48. Which operation can be used to multiply two integers using only bitshifts and addition?
A) Binary multiplication B) Ancient Egyptian multiplication C) Decimal multiplication D) Floating-point multiplication
- 49. Which operation is used to simplify complex bitwise expressions in compilers?
A) Integral calculus B) Boolean algebra C) Differential calculus D) Arithmetic algebra
- 50. Which operation is executed first according to the order of operations?
A) ( ) B) & C) | D) ^
- 51. Which operation is executed last according to the order of operations?
A) | B) ( ) C) ^ D) &
|