Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Twos Complement

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 8

Y10-02-P7

Two’s complement (2)


Y10-02-P7: Two’s complement (2)

Learning objectives
In this lesson you will learn to:

• convert between signed denary numbers and two's


complement binary numbers
• determine the range of values that can be represented in two's
complement by a binary number of a given length.

For more information about this topic and additional student activities
see Topic 2 of the student book.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

Two’s complement
We discussed two’s complement in a previous lesson.
What do you remember?

Two’s complement is the most common way of representing signed


binary integers.
There is only one way of representing 0.
This is better than sign magnitude representation. Can you
remember why?

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

Recap
In two’s complement, the most significant bit (MSB) is worth -128.

–128 64 32 16 8 4 2 1

What is the pattern for the highest value that can be represented in 8
bits?

What is the pattern for the lowest value that can be represented in 8-
bits?

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

Maximum and minimum values

–128 64 32 16 8 4 2 1
0 1 1 1 1 1 1 1

–128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

What is two’s complement and why is it needed?

Two’s complement is actually a clever mathematical solution.


As we saw before, the human-friendly minus sign cannot be
displayed in binary code.
Sign-magnitude representation has two values for 0. That’s not
particularly useful!
Two’s complement is much more useful as there is only one
value for 0 and mathematical operations actually work.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

Adding with two’s complement

Adding with binary patterns in two’s complement is the same as adding


any other binary pattern, including those that represent unsigned
numbers.
The four rules for addition are the same

0 0 0 0 0 1 1 1 = +7

1 1 1 1 1 0 1 1 + = –5

0 0 0 0 0 0 1 0 = +2

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-02-P7: Two’s complement (2)

Wrap up: so far you have learned how to…

 Convert between signed denary numbers and two's complement


binary numbers
• Remember that the MSB is its negative equivalent.

 Determine the range of values that can be represented in two's


complement by a binary number of a given length.
• Maximum value is 0 in MSB and 1s in every other bit.
• Minimum value is 1 in MSB and 0s in every other bit.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.

You might also like