Discussion
Bitwise can be used to reverse a sign of a number.
Answer: B
Correct answer: No
Negation in two's complement is ~x + 1, and that + 1 is ordinary addition, not a bitwise operation. Inverting the bits alone gives \( -x - 1 \), which is one short of the answer.
The reason is that bitwise operators work on each position independently and have no mechanism to propagate a carry, and changing a number's sign requires exactly that carry. XOR with a sign-bit mask flips the sign bit of a floating-point value, but that is a property of the IEEE format rather than of integer arithmetic.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development