0% found this document useful (0 votes)
31 views10 pages

Y10 01 P5 Slides v2

pearson edexcel binary slides 5

Uploaded by

molaposk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views10 pages

Y10 01 P5 Slides v2

pearson edexcel binary slides 5

Uploaded by

molaposk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Y10-01-P5:

Two’s complement (1)


Y10-01-P5: Two’s complement (1)

Learning objectives
In this lesson you will learn to:

• describe how positive and negative numbers are represented


in two's complement
• convert a two's complement binary number into denary
• use two’s complement to represent a signed denary number

For more detail on this topic, and additional student activities, refer to
Topic 2 of the student book.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Unsigned integers
Up to now, you have been working with unsigned integers.
These are whole numbers that are positive (0 or higher).

But what if you want to represent negative numbers?


In what situations might you need to represent negative numbers?

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Negative numbers
Computers cannot recognise the symbols ‘+’ or ‘-’.
These need to be represented in binary in some way.

One method is to replace the most significant bit (MSB) with a sign
bit.
This means that the leftmost bit will be 0 for positive numbers and 1
for negative numbers.
This method of representing signed numbers is called sign and
magnitude.
What would these binary numbers be in denary using this method?
1000 0000
What might the problems be with this method?

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

An alternative…
Another method is called two’s complement.
The most significant bit is a minus number as well as a sign bit.

–128 64 32 16 8 4 2 1
1 0 0 0 1 1 0 1
-128 8 4 1 = –115

The largest positive number that can be represented is 0111 1111


(i.e. +127)
The largest negative number that can be represented is 1000 0000
(i.e. –128)
Using two’s complement means there is only one value for 0.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Conversion method
In two’s complement, positive numbers are the same as normal.
Example:

–128 64 32 16 8 4 2 1
0 0 0 0 0 1 1 1
4 2 1 = +7

IMPORTANT
Note that the answer is +7, not just 7
This is important as this is a signed integer.
It must have the sign present.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Conversion method
In two’s complement, negative numbers look quite different from their
unsigned equivalents.
Example:

–128 64 32 16 8 4 2 1
1 1 1 1 1 0 1 1
-128 64 32 16 8 2 1 = -5

0 0 0 0 0 1 0 1

4 1 = +5

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Conversion method
You’ve looked at binary to denary conversions for two’s
complement, but how do you go back the other way?

For positive numbers, it’s just the same as you’ve done previously
using subtraction.

For negative numbers, there are some extra steps:

• convert the unsigned equivalent into 8-bit binary


• flip the bits (each 1 becomes a 0 and vice versa)
• add 1 (arithmetically, not appending).

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Worked Example

Let’s take the number -22 and convert it into binary using two’s
complement.

• 22 into 8-bit binary  0001 0110

• flip the bits  1110 1001

• add 1  1110 1010.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-01-P5: Two’s complement (1)

Wrap up: you have learned how to…


 Describe how positive and negative numbers are represented in
two's complement.
• The MSB is negative.
 Convert a two’s complement binary number into denary
 Use two’s complement to represent a signed denary number
• Flip the bits and add one.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy