0% found this document useful (0 votes)
23 views39 pages

Chapter 1.3, 1.4

Uploaded by

Shaoor Paracha
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)
23 views39 pages

Chapter 1.3, 1.4

Uploaded by

Shaoor Paracha
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/ 39

Chapter 1.

3
Addition of
binary number
Addition of binary number
Explanation

How do we perform add and carry in denary?

1
0+0=0 9
0+9=9 +1
9+0=9
10
9 + 1 = 10
Addition of binary number
Explanation

How do we perform add and carry in denary?

1 1
6+9 = 15 (>9)
56
1+5+7 = 13 (>9)
+79
1 35
Addition of binary number
Explanation

How do we perform add and carry in binary?

0+0=0
0+1=1
1+0=1
1 + 1 = 10
Addition of binary number
Explanation

How do we perform add and carry in binary?

1 1 1
00100111
+01001010
0 1110 001
Addition of binary number
DIY

How do we perform add and carry in binary?

Perform

01111110 + 00111110
Addition of binary number
Explanation

The overflow condition


1 11 111
01101110
+11011110
1 01 001 100
Addition of binary number
Explanation
1 11 111
The overflow condition 01101110
+11011110
1 01 001 100
• The maximum denary of an 8-bit binary number (11111111) is (2 8 -
1 ) = 255
• The generation of a 9th bit is a clear indication that the sum has
exceeded this value.
• This is known as an overflow error. The sum is too big to be stored
using 8 bits.
Addition of binary number
Explanation
1 11 111
The overflow condition 01101110
01101110 = 110 +11011110
\ 11011110 = 222 1 01 001 100

110 + 222 = 322


322 > 255 (overflow)
The sum is too big to be stored in a 8 bit binary.
Lesson
Chapter 1.4: Objectives
Binary Shifting
Last lesson on the binary system

BINARY SHIFTING TWO


COMPLEMENTS
Multiplication Represent
and division of negative
binary numbers number in
binary
BINARY SHIFTING

• Binary shift is a process that a CPU uses to perform


multiplication and division.
BINARY SHIFTING -
MULTIPLICATION
• For a CPU to multiply a binary number, the number
needs to be shifted to the left and will fill the remaining
gaps with zeros.
BINARY SHIFTING -
MULTIPLICATION
Examples: 111 (Binary)
64 32 16 8 4 2 1
0 0 0 0 1 1 1
Examples: 1110 (Binary)
64 32 16 8 4 2 1
0 0 0 1 1 1 0

Examples: 11100 (Binary)


64 32 16 8 4 2 1
0 0 1 1 1 0 0
BINARY SHIFTING -
MULTIPLICATION
Examples: 111 (Binary)
64 32 16 8 4 2 1
0 0 0 0 1 1 1

Multiply by 2, shift 1 place to the left 1110


Multiply by 4, shift 2 place to the left 11100
Multiply by 8, shift 3 place to the left 111000
Multiply by 2^n, shift n place to the left
BINARY SHIFTING - DIVISION

• For a CPU to DIVISION a binary number, the number


needs to be shifted to the right.
BINARY SHIFTING - DIVISION

Examples: 101100 (Binary)


32 16 8 4 2 1
1 0 1 1 0 0
Examples: 10110 (Binary)
32 16 8 4 2 1
0 1 0 1 1 0
Examples: 1011 (Binary)
32 16 8 4 2 1
0 0 1 0 1 1
BINARY SHIFTING - DIVISION

Examples: 101100 (Binary)


32 16 8 4 2 1
1 0 1 1 0 0

Divide by 2, shift 1 place to the right 10110


Divide by 4, shift 2 place to the right 1011
Divide by 8, shift 3 place to the right 101
Divide by 2^n, shift n place to the right
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS

• Registers contained within the CPU often have 8-bits limits


on the amount of data they can hold at any one time.
• The multiplying shifting process can cause bits to be lost at
one end of the register, and zeros added at the opposite end.
• This process is known as losing the most significant bit.
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS

Examples: 10110101 (181 in denary)


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

10110101 -> 01101010


106 in denary

The bit lost is called the most significant bit, and when it is shifted
beyond the furthest-column the binary data that is stored loses
precision due to overflow.
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS

The same process can happen when dividing an 8-bit


binary number.
Example: 10111101 (189 in denary)
128 64 32 16 8 4 2 1
1 0 1 1 1 1 0 1
Divide this number by 32 (move 5 places to the right)
128 64 32 16 8 4 2 1
0 0 0 0 0 1 0 1
The division shift produces the binary 11101
Least
number 101 = 5, not 5.9 that arithmetic Significant
suggests. bit
Chapter 1.5: Two Complements
Lesson Objectives
Last lesson on the binary system

BINARY SHIFTING TWO COMPLEMENTS

Represent negative
Multiplication
number in binary
and division of
binary numbers
TWO COMPLEMENTS

• A PROCESSOR CAN ALSO REPRESENT


NEGATIVE NUMBERS.
• ONE OF THE METHOD THAT A PROCESS
REPRESENT NEGATIVE NUMBERS IS
CALLED TWO'S COMPLEMENT.
TWO COMPLEMENTS
TWO COMPLEMENTS

• TO REPRESENT NEGATIVE NUMBERS, IT IS IMPORTANT


TO THINK ABOUT THE PLACE VALUE OF THE FURTHEST-
LEFT BIT IN A DIFFERENT WAY.
• PROCESSOR CAN BE SET UP TO SEE THE BIT IN THE
EIGHTH COLUMN AS A SIGN BIT.

0 = POSITIVE
1 = NEGATIVE
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-
BIT INTEGER

Examples:13
Step 1: Convert 13 into binary.
1101 in binary
Step 2: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 0 0 0 1 1 0 1

Step 3: Ensure that the the leftmost bit is 0 (+).


DI
Y

Convert 19 into a Two's complement


8-bit Integer
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-
BIT INTEGER

Examples:19
Step 1: Convert 19 into binary.
10011 in binary
Step 2: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 0 0 1 0 0 1 1
Step 3: Ensure that the the leftmost bit is 0 (+).

Answer: 00010011
CONVERT TWO'S COMPLEMENT 8-BIT INTEGER TO A POSITIVE BINARY INTEGER

Examples: Convert 00010011 (two's complement) to denary


Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 0 0 1 0 0 1 1
Step 2: This shows that it is a positive number, we can just
convert the binary into denary directly.
Step 3: Calculate the denary value.

(1x16) + (1x2) + (1x1) = 19


DI
Y

Convert 01010011 (two's complement)


to denary
CONVERT TWO'S COMPLEMENT 8-BIT INTEGER TO A POSITIVE
BINARY INTEGER

Examples: Convert 01010011 (two's complement) to denary


Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 1 0 1 0 0 1 1
Step 2: This shows that it is a positive number, we can just
convert the binary into denary directly.
Step 3: Calculate the denary value.

(1x64) + (1x16) + (1x2) + (1x1) = 83


CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT
FORMAT AND CONVERT TO DENARY

Examples: 10010011
Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
1 0 0 1 0 0 1 1
Step 2: The left-most bit is 1, this means that it is a negative
number.
Step 3: Compute the denary value as usual.
(1x -128) + (1x16) + (1x2) + (1x1)
= -128 + 16 + 2 + 1
= -109
DI
Y

Convert 10110011 (Two's Complement)


to denary
CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT
FORMAT AND CONVERT TO DENARY

Examples: 10110011
Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 1
Step 2: The left-most bit is 1, this means that it is a negative
number.
Step 3: Compute the denary value as usual.
(1x -128) (1x32)+ (1x16) + (1x2) + (1x1)
= -128 + 32 + 16 + 2 + 1
= -77
CONVERTING NEGATIVE DENARY NUMBERS INTO BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT

Examples: -67
Step 1: Convert the number to positive.
67
Step 2: Write the number in binary form (8 bits).
01000011
Step 3: Invert each binary value.
10111100
Step 4: Add 1 to the binary number.
10111100
+ 1
10111101
Step 5: This gives us -67.
-128 64 32 16 8 4 2 1
1 0 1 1 1 1 0 1
-128 + 32 + 16 + 8 + 4 + 1 = -67
DI
Y

Convert -65 to 8 bit two's complement


binary number
CONVERTING NEGATIVE DENARY NUMBERS INTO BINARY NUMBERS IN
TWO’S COMPLEMENT FORMAT

Examples: -65
Step 1: Convert the number to positive.
65
Step 2: Write the number in binary form (8 bits).
01000001
Step 3: Invert each binary value.
10111110
Step 4: Add 1 to the binary number.
10111110
+ 1
10111111

Step 5: This gives us -65.


-128 64 32 16 8 4 2 1
1 0 1 1 1 1 1 1
-128 + 32 + 16 + 8 + 4 + 2 + 1 = -65
Summary: Convert negative denary to two's complement
Examples: -65

65 Convert to (+)

01000001 Convert to binary

10111110 Invert the digit

1 +1

10111111 Final result

You might also like