8-bit Two’s Complement — Determine the 8-bit two’s-complement representation of the decimal value −9.

Difficulty: Easy

Correct Answer: 11110111

Explanation:


Introduction:
Converting a negative decimal integer to two’s-complement involves finding the binary of the positive magnitude, inverting all bits, and adding 1, constrained to the chosen word size. Here, we compute the 8-bit code for −9 and match it against the options provided.

Given Data / Assumptions:

  • Word size = 8 bits.
  • Target value = −9 (decimal).
  • Representation scheme = two’s-complement.


Concept / Approach:
Two equivalent ways exist: (1) encode +9 into binary, invert and add 1; or (2) start from a candidate negative code and convert back to magnitude for confirmation. We will use method (1) to derive the correct 8-bit pattern.

Step-by-Step Solution:

Step 1: +9 (decimal) in binary (8 bits) is 00001001₂.Step 2: Invert bits: 11110110₂.Step 3: Add 1: 11110110₂ + 1 = 11110111₂.Step 4: Compare with options; 11110111 is present.


Verification / Alternative check:

Convert 11110111 back: invert → 00001000; +1 → 00001001 = 9; MSB = 1 → negative ⇒ −9, confirming correctness.


Why Other Options Are Wrong:

11111001: Equals −7 (check by two’s-complement back-conversion).11110110: This is the one’s-complement of +9; adding 1 yields the correct code.01111101: MSB = 0, so this is a positive number (125), not a negative code.


Common Pitfalls:

Forgetting to pad to 8 bits before inversion.Stopping at one’s-complement and skipping the +1 step.


Final Answer:

11110111

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion