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