number systems revision of conversations what is a register addition complementation

31
Number Systems Revision of conversations What is a register Addition Complementation

Upload: andrea-harrington

Post on 05-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Number Systems Revision of conversations What is a register Addition Complementation

Number Systems

Revision of conversationsWhat is a registerAdditionComplementation

Page 2: Number Systems Revision of conversations What is a register Addition Complementation

Revision of conversionsDecimal Binary Hexadecim

al 101012

34010

1011102

100111112

3816

45010

C6716

B2116

4410

Page 3: Number Systems Revision of conversations What is a register Addition Complementation

AnswersDecimal Binary Hexadecim

al 2110 101012 1516

34010 1010101002 15416

4610 1011102 2E16

15910 100111112 9F16

5610 001110002 3816

45010 1110000102 1C216

317510 1100011001112

C6716

284910 1011001000012

B2116

4410 1011002 2C16

Page 4: Number Systems Revision of conversations What is a register Addition Complementation

Home WorkConvert the following

Decimal Binary Hexadecimal

1110112

5510

0000112

010101002

A9E16

19910

Page 5: Number Systems Revision of conversations What is a register Addition Complementation

What is a Register?A small amount of very fast

computer memory

Speed up computer programs.

Store most commonly used values,

Computers load information into the registers, and then load it back to the main memory (load-store architecture)

Page 6: Number Systems Revision of conversations What is a register Addition Complementation

Registers If we have a 5 bit register the

maximum number of bits it can store is 5

Since it can hold 5bits we could have 25 combinations (32)

The range of the register would be

0 – 25-1 = 0 - 31

Page 7: Number Systems Revision of conversations What is a register Addition Complementation

Working with Registers If we had a 12 bit register how

many bits could it hold? How many combinations would

the register be able to hold?

What would the range of the register be?

Page 8: Number Systems Revision of conversations What is a register Addition Complementation

Home WorkFind the following for registers A,

B and C1. How many bits would each one

hold?2. How many combinations could

be made in each register?3. What would the range of

numbers be for each one?A. 10B. 8C. 14

Page 9: Number Systems Revision of conversations What is a register Addition Complementation

Addition We could perform addition on

binary numbers

Here are some examples;

0+ 0+ 1+ 1+ 1+

0 1 0 1 1 1

0 1 1 10 11

Page 10: Number Systems Revision of conversations What is a register Addition Complementation

REMEMBER If we remember the following

rules we will have no problems when performing additions

0 + 0 =

0

0 +1= 11 + 0 =

1

1 + 1 =

10

1 + 1 + 1

11

0112 3

Page 11: Number Systems Revision of conversations What is a register Addition Complementation

Trying out additions

100+ 1001+ 111+

011 0011 001

Page 12: Number Systems Revision of conversations What is a register Addition Complementation

Answers

100+ 1001+ 111+

011 0011 001

111 1100 1100

Page 13: Number Systems Revision of conversations What is a register Addition Complementation

Home work

1110+ 0101+ 1101+

1111 0110 0100

0101+ 1000+ 1110+

0111 1001 1010

Page 14: Number Systems Revision of conversations What is a register Addition Complementation

ComplementationComplementation is a used to represent

positive and negative numbers. In binary

This system requires numbers to be represented by a fixed number of bits.

There are two forms of complementation, one’s complement and two’s complement.

Page 15: Number Systems Revision of conversations What is a register Addition Complementation

Ones Complement One’s complement is used to represent

negative numbers

Lets say we have 4510

When using 8 bits 4510 = 001011012

If we change 4510 to -4510 The binary representation changes by converting 0s to 1s and 1s to 0s;

001011012 110100102. after ones complement

Page 16: Number Systems Revision of conversations What is a register Addition Complementation

Examples Change the following to negative

binary numbers using one’s complement

Decimal Binary One’s Complement

10910

22910

6410

8910

Page 17: Number Systems Revision of conversations What is a register Addition Complementation

Answers

Decimal Binary One’s Complement

10910 11011012 00100102

22910 111001012 000110102

6410 10000002 01111112

8910 010110012 101001102

Page 18: Number Systems Revision of conversations What is a register Addition Complementation

Two’s Complement Two’s complement allows us to

perform subtractions with binary numbers

With two’s complement we start converting 1s to 0s and 0s to 1s after the first 1

Lets take the previous example of -4510,

Decimal Binary Two’s complement

4510 001011012 110100112

Page 19: Number Systems Revision of conversations What is a register Addition Complementation

Another example Lets say we had the number 1710

and we want to change it to a -17 in two’s complement

First we convert 1710 to binary using an 8 bit register = 000100012

Starting after the first 1 we convert the bits = 111011112

Page 20: Number Systems Revision of conversations What is a register Addition Complementation

Examples Change the following negative

numbers to binary using two’s complement and an 8 bit register ;Decimal Binary Two’s

Complement

-1010

-4210

-5510

-6010

Page 21: Number Systems Revision of conversations What is a register Addition Complementation

Answers

Decimal Binary Two’s Complement

-1010 000010102 111101102

-4210 001010102 110101102

-5510 001101112 110010012

-6010 001111002 110001002

Page 22: Number Systems Revision of conversations What is a register Addition Complementation

Home Work Convert the following negative

numbers into binary using one’s and twos complement;

Decimal

Binary

One’s Complement

Two’s Complement

5610

8910

6710

2110

4910

Page 23: Number Systems Revision of conversations What is a register Addition Complementation

Numerical OverflowAn overflow is when something

doesn’t fit in a certain space

Numeric overflow is when the storage for a calculation is too small to hold the result

For example we have an 8 bits register, if we add two binary numbers and the result turns out to be 9 bits it would not fit in the register

Page 24: Number Systems Revision of conversations What is a register Addition Complementation

Example Let’s say we have an 8 bit

register

Add the following;

Do we have an overflow?

11111111+

10101010

Page 25: Number Systems Revision of conversations What is a register Addition Complementation

Numerical OverflowWhen we have a numeric overflow we

will have an error in our calculation

When we have an overflow we would need to remove the extra bit at the start of the number

Lets say we had a 7 bit register and the result of a calculation is 11001100 the actual answer would be 1001100

Page 26: Number Systems Revision of conversations What is a register Addition Complementation

Example Let’s say we have a 7 bit register

Add the following;

Do we have an overflow? Actual answer =

1101111+

1101101

Page 27: Number Systems Revision of conversations What is a register Addition Complementation

What is Bit Shifting?Bit shifting is the process of moving

all the bits in a binary number

We have two shifts1. A right shift2. A left shift

The right shift would divide the number while the left would multiply it

Page 28: Number Systems Revision of conversations What is a register Addition Complementation

Right Shift The right shift is used for If we shift the byte 001101112 left once,

we get 011011102. If we shift 101100112, right by three places, we get 000101102. Notice in the right-shift example that bits that are shifted out of the byte are lost. This also occurs with left-shifting: if any bits are shifted outside of the "boundaries" of the type in use (eight bits, for a byte), they are lost.

Page 29: Number Systems Revision of conversations What is a register Addition Complementation

Left Shift

Page 30: Number Systems Revision of conversations What is a register Addition Complementation

Right Shift

Page 31: Number Systems Revision of conversations What is a register Addition Complementation

Ranges