- 1. What is the result of the bitwise NOT operation on the binary value 0111 (decimal 7)?
A) 1000 (decimal 8) B) 1111 (decimal 15) C) 0001 (decimal 1) D) 0110 (decimal 6)
- 2. Which bitwise operation is used to determine whether a particular bit is set or cleared?
A) AND B) NOT C) XOR D) OR
- 3. What is the result of the bitwise AND operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0001 (decimal 1) B) 0111 (decimal 7) C) 0011 (decimal 3) D) 0100 (decimal 4)
- 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 highest valued bit is 0 using NOT C) Check if the lowest valued bit is 1 using XOR with 0001 (decimal 1) D) Check if the lowest valued bit is 0 using AND with 0001 (decimal 1)
- 5. What is the result of the bitwise OR operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0111 (decimal 7) B) 0010 (decimal 2) C) 0100 (decimal 4) D) 1000 (decimal 8)
- 6. What is the result of the bitwise XOR operation between 0101 (decimal 5) and 0011 (decimal 3)?
A) 0101 (decimal 5) B) 0110 (decimal 6) C) 0111 (decimal 7) D) 0000 (decimal 0)
- 7. Which bitwise operation can be used to toggle bits in a register?
A) XOR B) OR C) AND D) NOT
- 8. What is the result of the bitwise AND operation between 0110 (decimal 6) and 1011 (decimal 11)?
A) 0101 (decimal 5) B) 0000 (decimal 0) C) 0010 (decimal 2) D) 1111 (decimal 15)
- 9. How can you set the fourth bit of 0010 (decimal 2) using bitwise operations?
A) Perform a bitwise OR with 1000 (decimal 8) B) Perform a bitwise XOR with 1000 (decimal 8) C) Perform a bitwise NOT with 1000 (decimal 8) D) Perform a bitwise AND with 1000 (decimal 8)
- 10. Which bitwise operation is often used to invert a grayscale image?
A) NOT B) XOR C) AND D) OR
- 11. What is the result of the bitwise OR operation between 0010 (decimal 2) and 1000 (decimal 8)?
A) 1011 (decimal 11) B) 0010 (decimal 2) C) 1010 (decimal 10) D) 1000 (decimal 8)
- 12. What is the result of the bitwise NOT operation on 10101011 (decimal 171)?
A) 10101010 (decimal 170) B) 01010101 (decimal 85) C) 01010100 (decimal 84) D) 11111111 (decimal 255)
- 13. How can you set a register to zero using XOR?
A) Perform NOT on the register B) Perform AND on the register with zero C) Perform XOR on the register with itself 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) (2floor(log2(x) + 1) - 1) - x C) x XOR y D) x OR y
- 15. Which bitwise operation is used to set selected bits to 1?
A) NOT B) AND C) XOR D) OR
- 16. What is the result of the bitwise XOR operation between 0101 (decimal 5) and 0101 (decimal 5)?
A) 1111 (decimal 15) B) 1010 (decimal 10) C) 0101 (decimal 5) D) 0000 (decimal 0)
- 17. What is the result of the bitwise OR operation between 0101 (decimal 5) and 0101 (decimal 5)?
A) 0000 (decimal 0) B) 1010 (decimal 10) C) 0101 (decimal 5) D) 1111 (decimal 15)
- 18. How many possible truth functions are there for two binary variables?
A) 16 B) 32 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) Boolean operation C) Opcode D) Bitwise operation
- 21. How many operations are there in a bitwise ternary logic instruction?
A) 256 B) 128 C) 16 D) 64
- 22. What orientation is used when a left shift increases the value of a number?
A) Little-endian B) Middle-endian C) Big-endian D) Small-endian
- 23. What is the effect of multiple shifts shortened to a single shift by some number of digits?
A) Equivalent to shifting by double that number of digits B) Equivalent to shifting by that number of digits C) Equivalent to shifting by half 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) Shifted-out bits C) Sign bits D) Carry bits
- 25. What is the dominant representation in the current marketplace for arithmetic shifts?
A) Two's complement B) Floating point C) Ones' complement D) Sign magnitude
- 26. What happens to the bits that are shifted out of either end in an arithmetic shift?
A) They are copied B) They are preserved C) They are discarded D) They are inverted
- 27. Which type of shift is ideal for unsigned binary numbers?
A) Logical right-shift B) Rotate through carry C) Circular shift D) Arithmetic right-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) Undefined behavior B) Circular shift C) Arithmetic shift D) Logical shift
- 31. In C#, what type of shift is performed when the first operand is an int or long?
A) Rotate through carry B) Logical shift C) Circular shift D) Arithmetic shift
- 32. In C#, what type of shift is performed when the first operand is of type uint or ulong?
A) Rotate through carry B) Logical shift C) Arithmetic shift D) Circular shift
- 33. What is the behavior of right-shifting a negative value in C and C++?
A) Arithmetic shift B) Circular shift C) Implementation-defined D) Logical 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) A logical right-shift B) An arithmetic 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++20 B) C++14 C) C++11 D) C++17
- 37. What is the recommended way to avoid undefined behavior and branches in GCC and Clang for circular shifts?
A) Use a recognized pattern for a single rotate instruction B) Use a branch to check shift amount C) Use multiple machine instructions D) Use arithmetic shifts
- 38. Which compiler provides intrinsics like _rotl8, _rotl16, _rotr8, _rotr16?
A) Intel B) Microsoft Visual C++ C) GCC D) Clang
- 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) 0x3f (0b111111) C) 0x1f (0b11111) D) 0xff (0b11111111)
- 42. Which of the following is a compiler-specific intrinsic for circular shifts in Microsoft Visual C++?
A) __builtin_stdc_rotate_right B) __builtin_stdc_rotate_left C) std::rotl D) _rotl16
- 43. What is the recommended way to perform circular shifts in high-integrity software?
A) Use branches to check shift amount B) Use multiple machine instructions C) Use compiler-recognized patterns for single rotate instructions D) Use arithmetic shifts
- 44. Which of the following is a compiler-specific intrinsic for circular shifts in GCC 15?
A) __builtin_stdc_rotate_right B) __builtin_stdc_rotate_left C) std::rotl D) _rotl16
- 45. What is the mask value used for the right-hand operand in Java when the left-hand operand is of type long?
A) 0x1f (0b11111) B) 0x0 (0b00000000) 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) bitwise AND D) popcount
- 47. Which programming domain often requires bitwise operations?
A) Device drivers B) Database management C) User interface design D) Web development
- 48. Which operation can be used to multiply two integers using only bitshifts and addition?
A) Ancient Egyptian multiplication B) Binary multiplication C) Floating-point multiplication D) Decimal multiplication
- 49. Which operation is used to simplify complex bitwise expressions in compilers?
A) Arithmetic algebra B) Boolean algebra C) Integral calculus D) Differential calculus
- 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) ( )
|