Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
Two’s-complement encoding enables the same adder circuitry to handle both positive and negative integers, simplifying hardware and enabling efficient arithmetic. It is pervasive across ISAs and microarchitectures.
Given Data / Assumptions:
Concept / Approach:
Two’s complement represents −x as (~x) + 1. Using this scheme, subtraction A − B becomes A + (~B + 1), so a single binary adder suffices for addition and subtraction. Sign bit participates naturally in the addition, avoiding special sign handling required by sign-magnitude or one’s-complement schemes.
Step-by-Step Solution:
1) Encode negatives by inversion plus 1.2) Perform A − B as A + (two’s-complement of B).3) Use overflow rules: for addition, overflow occurs when adding two numbers with the same sign produces a result with the opposite sign.4) Hardware uses the same adder for both operations, minimizing complexity.
Verification / Alternative check:
Survey architectures (x86, ARM, RISC-V, MIPS); all use two’s complement for signed integers.
Why Other Options Are Wrong:
“Incorrect” contradicts standard practice. “Only for floating-point” is wrong—floating point uses IEEE-754, not two’s complement. “Replaced by sign-magnitude” is historically reversed.
Common Pitfalls:
Confusing encoding for integers with floating-point formats; misapplying overflow rules across representations.
Final Answer:
Correct
Discussion & Comments