Illustration for Two’s Complement Examples for Beginners - DigiToolkit

Two’s Complement Examples for Beginners

Beginner two’s complement examples at 4-bit and 8-bit, from -5 and -20 to minus one and the minimum value, worked step by step for exams.

Quick Answer: Two’s complement examples show how computers store negative numbers by inverting the bits and adding one. For instance, the 4-bit two’s complement of 5 (0101) is 1011, which represents -5, and the 8-bit two’s complement of 20 (00010100) is 11101100, representing -20. Working through examples like these is the fastest way for Indian students to master signed binary for CBSE and GATE.

Key takeaways:

  • Every example uses the same rule: invert the bits, then add one.
  • The 4-bit two’s complement of 5 is 1011, meaning -5.
  • The 8-bit two’s complement of 20 is 11101100, meaning -20.
  • A number plus its two’s complement equals zero within the bit width.
  • Examples build the intuition needed for CBSE and GATE questions.

The quickest way to get comfortable with two’s complement is to work through plenty of examples. Rules make sense only when you see them applied, and the same short procedure repeated across different numbers soon becomes second nature. This beginner reference collects clear two’s complement examples at 4-bit and 8-bit widths, all worked out step by step.

These examples map directly onto the kinds of questions asked in Indian CBSE Class 11 exams, engineering digital-logic papers and GATE, so practising them is time well spent.

Key takeaway: Every two’s complement example is the same two steps in disguise: flip all the bits, then add one. Change the number and the width, and the method never changes.

Example 1: Positive Numbers Stay the Same

The simplest example is a positive number. In two’s complement, a positive value is written exactly like ordinary binary, with a 0 sign bit at the front. So 5 in four bits is 0101, and 20 in eight bits is 00010100. No inversion is needed for positives; the two’s complement process is only used to create their negatives.

Example 2: The Two’s Complement of 5 (4-bit)

Take 5, which is 0101. Invert every bit to get 1010, the one’s complement. Add one: 1010 plus 0001 equals 1011. So the 4-bit two’s complement of 5 is 1011, representing -5. The leading 1 confirms it is negative. To check, add 0101 and 1011 to get 10000; discard the fifth bit and you are left with 0000, which is zero.

Example 3: The Two’s Complement of 20 (8-bit)

Write 20 as 00010100 in eight bits. Invert to 11101011, then add one to get 11101100. This is the 8-bit two’s complement of 20, representing -20. Verify by adding 00010100 and 11101100: the sum is 100000000, and discarding the ninth bit leaves 00000000, confirming the pair sums to zero.

Example 4: Reading a Negative Pattern

Now go the other way. Given 11111011 in eight bits, the sign bit is 1, so the value is negative. Take its two’s complement: invert to 00000100, add one to get 00000101, which is 5. Therefore 11111011 represents -5. This reverse reading appears constantly in exams and is just the same procedure applied again.

Example 5: The Special Case of Minus One

Minus one is a memorable example. In any width, minus one is all ones: 1111 in four bits, 11111111 in eight bits. You can see why by taking the two’s complement of 1 (0001): invert to 1110, add one to get 1111. This all-ones pattern for minus one is worth memorising because it appears so often.

Decimal 8-bit two’s complement Sign bit
20 00010100 0 (positive)
-20 11101100 1 (negative)
-1 11111111 1 (negative)
-128 10000000 1 (negative)

Example 6: The Minimum Value

The most negative 8-bit number is minus 128, stored as 10000000. It has no positive counterpart within eight bits, because the positive maximum is only 127. This asymmetry, one extra negative value, is a classic exam point and follows directly from the range formula of -2 to the power (n-1) up to 2 to the power (n-1) minus 1.

Benefits of Practising Examples

Working through examples turns an abstract rule into a reliable skill. Each example reinforces the invert-and-add-one method, the role of the sign bit and the zero-sum check, so the concept becomes automatic. For Indian students facing timed CBSE and GATE questions, this fluency means fewer mistakes and faster answers. Examples also reveal patterns, like all-ones for minus one, that speed up future calculations.

Challenges and Limitations

Examples are snapshots at a single bit width, so you must always confirm the width before comparing. The same pattern means different values at 4, 8 or 16 bits, which can confuse beginners who skip that step. Overflow is another subtlety: examples that stay within range behave neatly, but real calculations can wrap around. Treat each example as practice of the method, not as a fixed fact independent of width.

Common Mistakes to Avoid

  • Inverting positives unnecessarily. Positive numbers are written directly; only negatives use the full process.
  • Skipping the add-one. Without it you have only the one’s complement.
  • Ignoring the width. Always pad to the full number of bits before inverting.
  • Misreading the sign bit. A leading 1 means negative, so do not read it as a large positive.
  • Forgetting the zero-sum check. A number plus its two’s complement must give zero within the width.
  • Confusing minus one and minus 128. All-ones is minus one; a single leading one is the minimum value.

Best Practices and Expert Recommendations

  • Work many small examples. Repetition at 4-bit and 8-bit builds real fluency.
  • Always verify by addition. Confirm each result sums to zero with its original.
  • Memorise key patterns. Remember all-ones for minus one and the minimum-value pattern.
  • Practise the reverse direction. Read negative patterns back to decimal regularly.
  • State the width in every answer. Make the bit width explicit to avoid confusion.
  • Check with a calculator. Use a two’s complement calculator to confirm your examples while learning.

Conclusion

Two’s complement examples make a tricky idea concrete by showing the same simple rule, invert and add one, applied again and again. From the two’s complement of 5 to the special cases of minus one and the minimum value, each example strengthens your grasp of signed binary. Practise widely, verify by addition, and memorise the key patterns, and you will be ready for any two’s complement question in CBSE or GATE.

A 4-bit Reference Walkthrough

A powerful way to internalise two’s complement examples is to build the full four-bit signed table yourself and study its structure. In four bits, the positive values run from 0000 for zero up to 0111 for seven, all with a leading zero sign bit. The negative values occupy the patterns with a leading one, from 1111 for minus one down to 1000 for minus eight. Reading down this table reveals the wrap-around behaviour clearly: counting up from 0111 does not reach eight but instead rolls over to 1000, which is minus eight, the most negative value.

Walking through the table also makes the famous asymmetry obvious. There are eight negative values, from minus one to minus eight, but only seven positive values, from one to seven, because zero occupies one of the positive-side patterns. This is the direct, visible consequence of the range formula, and seeing it laid out removes the mystery. Students who take fifteen minutes to write out this small table by hand, converting each pattern back to decimal using the invert-and-add-one rule, tend to remember the behaviour far longer than those who only read about it. The same exercise scales conceptually to eight and sixteen bits, where the patterns are longer but the structure is identical, so mastering the four-bit case builds intuition for every larger width.

Expert Takeaways

  • Build the table yourself. Writing out the full four-bit signed table cements the patterns better than reading alone.
  • See the wrap-around. Counting past the maximum rolls over into the most negative value, which is the heart of the idea.
  • Notice the asymmetry. There is always one more negative value than positive because zero sits on the positive side.
  • Small scales up. The four-bit structure is identical at 8, 16 and 32 bits, so start small and generalise.

Practising Beyond Four Bits

Once the four-bit examples feel comfortable, the best way to consolidate your skill is to repeat the same exercises at eight bits, which is the width most exams and real programs actually use. The procedure is completely unchanged: pad the number to eight positions, invert every bit, then add one. What grows is only the length of the patterns, so a value like minus twenty becomes 11101100 rather than a short four-bit code. Working several eight-bit examples helps you become fluent with longer strings without losing track, a common source of careless slips. It also lets you meet the eight-bit landmarks that examiners love, such as the minimum value of minus 128 stored as 10000000, the maximum of 127 stored as 01111111, and minus one as the all-ones pattern 11111111. Writing out ten or twelve such conversions by hand, then checking each with a calculator, builds both speed and confidence. Because the same logic scales identically to sixteen and thirty-two bits, this eight-bit practice prepares you for every width you are likely to encounter in Indian coursework, entrance tests and professional programming alike.

Frequently Asked Questions

What is a basic two’s complement example?

A basic example is the 4-bit two’s complement of 5. Write 5 as 0101, invert to 1010, then add one to get 1011, which represents -5. The leading 1 shows the value is negative.

Why is minus one all ones in two’s complement?

Taking the two’s complement of 1 (0001) gives 1111 in four bits: inverting produces 1110 and adding one gives 1111. This all-ones pattern represents minus one at any bit width, which is why it is worth memorising.

How can I check a two’s complement answer?

Add the original number to your two’s complement result. Within the fixed bit width, discarding any final carry, the sum should be zero. If it is not, recheck your invert-and-add-one steps.

Why can 8 bits store -128 but not +128?

The signed 8-bit range runs from -128 to 127 because one bit is used for the sign, leaving room for one extra negative value. So 10000000 represents -128, while +128 is out of range and would require more bits.

Leave a Reply

Your email address will not be published. Required fields are marked *