Which of the following is/are bit manipulation operators ? 1. || 2.

Which of the following is/are bit manipulation operators ?

  • 1. ||
  • 2. ^
  • 3. >>
  • 4. <<

Select the correct answer using the code given below :

1 only
1, 2 and 3
2 and 4 only
1, 2 and 4
This question was previously asked in
UPSC CISF-AC-EXE – 2020
Bit manipulation operators (or bitwise operators) perform operations on individual bits of integers. From the given list:
1. `||` is the logical OR operator, which operates on boolean values (or treats non-zero as true). It is not a bit manipulation operator.
2. `^` is the bitwise XOR operator, which compares corresponding bits and returns 1 if they are different, and 0 if they are the same. This is a bit manipulation operator.
3. `>>` is the bitwise right shift operator, which shifts all bits in an operand to the right by a specified number of positions. This is a bit manipulation operator.
4. `<<` is the bitwise left shift operator, which shifts all bits in an operand to the left by a specified number of positions. This is a bit manipulation operator. Operators 2 (`^`), 3 (`>>`), and 4 (`<<`) are bit manipulation operators. Option C lists 2 and 4 only. While 3 is also correct, Option C contains only correct operators from the list, unlike options B and D which incorrectly include 1 (`||`). Given the options, C is the most plausible correct answer, assuming it lists a subset of the correct operators from the provided list.
– Bitwise operators work on the binary representation of numbers.
– Common bitwise operators include AND (`&`), OR (`|`), XOR (`^`), NOT (`~`), left shift (`<<`), and right shift (`>>`).
– Logical operators (`&&`, `||`, `!`) work on boolean values.
The options provided seem incomplete as `>>` (3) is also a bit manipulation operator. However, option C correctly identifies two bit manipulation operators from the list without including any incorrect ones.