You are on page 1of 7

Addition of Binary Numbers

Addition of binary numbers


• If adding 23 and 28 in denary. Examples: convert the denary value 82
and 69 to binary, then add them up.
• Add the numbers in the right hand column
first Solution:
• If the sum is greater than 9 then we carry a • First convert the denary numbers to binary
value to the next column • Carry out addition, clearly write out the Carry
• We continue moving left, adding any carry • 82 = 01010010 and 69 = 01000101
values to each column until we are finished
01010010
23
+ 01000101
+ 28
1 Carry
1 Carry value
10010111 Sum value

5 1 Sum value
Overflow Error
The generation of a 9th bit is a clear
NOTE: indication that the sum has exceeded this
value. This is known as an overflow error.
Adding in binary follows the same rules This may lead to the computer ignoring
except that we carry whenever the sum is the extra bit, that leads to error.
greater than 1.
It is always adviceable to use larger bits to
store values to avoid overflow.
• The maximum denary value of an 8-
bit binary number is 255 (which is 28
–1
• An overflow error is an indication
that a number is too big to be stored
in the computer using 8 bits.

• In this case, the bits for storage can be


increased to 12 bits or 16 bits.
• The greater the number of bits which
can be used to represent a number
then the larger the number that can
be stored.
LOGICAL SHIFTS
Logical binary shifts
• The logical shift means moving the binary Example: The denary number 21 is 00010101
number to the left or to the right. in binary
128 64 32 16 8 4 2 1

• Each shift left is equivalent to 0 0 0 1 0 1 0 1

multiplying the binary number by 2 and


each shift right is equivalent to dividing
the binary number by 2

If we now shift the bits in this register one


• As bits are shifted, any empty positions place to the left
are replaced with a zero
128 64 32 16 8 4 2 1

• Eventually after a number of shifts the 0 0 1 0 1 0 1 0


register would only contain zeros

The new value will become= 32+8+2 = 42


• Suppose we now shift the original number • Class Exercise
two places left = 21 * 22 = 21 * 4
128 64 32 16 8 4 2 1 Convert 29 and 51 to 8-bit binary numbers.
0 1 0 1 0 1 0 0 • Add the two binary numbers in part
• Shift the result in part a. three places to the
The value after the shift to the left right.
will be = 64+16+4= 84
Solution:
Example: Suppose we have a denary value 29 in binary = 00011101
of 180 with binary value of 10110100 51 in binary = 00110011 +
Carry value= 1 1 1 1 1 1
128 64 32 16 8 4 2 1 Add 29 and 51= 01010000 = 80
1 0 1 1 0 1 0 0 128 64 32 16 8 4 2 1

And we move 2 steps to the right, what 0 1 0 1 0 0 0 0

will be our new value = 180 / 22 =180/4 Logical shift: three places to the right.
Each shift is 2 so in three places= 23= 2*2*2=8
We are dividing the binary be 8 because we are moving three places to the right
128 64 32 16 8 4 2 1
128 64 32 16 8 4 2 1 Move to the right is division
80/23 = 80/8 = 10
0 0 1 0 1 1 0 1
0 1 0 1 0 0 0 0

The new value will be 32+8+4+1 = 45


128 64 32 16 8 4 2 1 New value after
logical shift of three
0 0 0 0 1 0 1 0 places =8 + 2=10
Holiday Homework
• Convert the following pairs of denary a. Write down the denary value of the
numbers to 8-bit binary numbers and then following binary number.
add the binary numbers. Comment on
your answers in each case:
• 01101000
a. 89 + 175
b.168 + 99 b. Shift the binary number three places
to the right and comment on your
c. 88 + 215 result.

• Carry out the following 16-bit and 8-bit c. Write down the denary value of the
binary additions and comment on your following binary number.
answers(show carry and sum value):
• 00001111
a. 0111 1111 1111 0001 +
0101 1111 0011 1001 d. Shift the binary number four places to
the left and comment on your result
b. 1 0 1 0 0 0 1 0 +
00111011

You might also like