Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Arithmetic Operations

Dolly Indra

Arithmetic/Digital System/FIK/Dolly Indra/2015


To be learned
• Binary Arithmetic
• Two’s-Complement
• Hexa Decimal Arithmetic

Arithmetic/Digital System/FIK/Dolly Indra/2015


Binary Arithmetic
• The rules :
1. 0 + 0 = 0, carry 0
2. 0 + 1 = 1 , carry 0
3. 1 + 0 = 1 , carry 0
4. 1 + 1 = 0 , carry 1

Arithmetic/Digital System/FIK/Dolly Indra/2015


Example :
Decimal Binary
(a) 5 0 0 0 0 01 0 1
2 0 0 0 0 0 01 0
+ +
7 0 0 0 00 1 1 1 = 7(10)

1 1
(b) 18 0 0 0 1 00 1 0
2 0 0 0 0 0 01 0
+ +
20 0 0 0 1 0 1 0 0 = 20
(10)
Arithmetic/Digital System/FIK/Dolly Indra/2015
Exercises
• Perform the following decimal additions and convert the
original decimal members to binary and add them.
Decimal Decimal
(a) 8 (c) 50
3 6
+ +

(b) 31 (d) 147


7 75
+ +

Arithmetic/Digital System/FIK/Dolly Indra/2015


Two’s-Complement Representation
• The most widely used method of representing
binary numbers and performing arithmetic in
computer systems is by using the two’s-
complement method. With the method, both
positive and negative numbers can be
represented using the same format, and
binary substraction is greatly simplified.

Arithmetic/Digital System/FIK/Dolly Indra/2015


Attention This Table Below :
Decimal Two’s Complement
+7 0000 0111
+6 0000 0110
+5 0000 0101
+4 0000 0100
+3 0000 0011
+1 0000 0001
0 0000 0000
-1 1111 1111
-2 1111 1110
-3 1111 1101
-4 1111 1100
-5 1111 1011
-6 1111 1010
-7 1111 1001
-8 1111 1000
Arithmetic/Digital System/FIK/Dolly Indra/2015
Steps for Decimal-to-Two’s-Complement Conversion
1. If the Decimal number is positive, the two’s
complement number is the true binary equivalent of
the decimal number. (for example : +18 = 0001 0010).
2. If the decimal number is negative, the two’s
complement number is found by :
(a) Complementing each bit of the true binary
equivalent of the decimal number (this is called the
one’s complement).
(b) Adding 1 to the one’s-complement number to get
the magnitude bits (the sign bit will always end up
being 1).
Arithmetic/Digital System/FIK/Dolly Indra/2015
Example :

Convert +35(10) to two’s complement

True binary = 0010 0011

Two’s complement = 0010 0011

Arithmetic/Digital System/FIK/Dolly Indra/2015


Example :
Convert -1 (10) to two’s complement

True binary = 000 0 0001

One’s complement = 111 1 1110


Add 1 = 1 +

Two’s complement = 1 1 1 1 1 1 1 1

Arithmetic/Digital System/FIK/Dolly Indra/2015


Example :
Convert -35 (10) to two’s complement

True binary = 000 0 0010 0011

One’s complement = 111 1 1101 1 100


Add 1 = 1
+

Two’s complement = 1 1 1 1 1 1 0 1 1 10 1
Arithmetic/Digital System/FIK/Dolly Indra/2015
Hexadecimal Arithmetic
• The procedure for adding hex digits is as follows :
1. Add the two hex digits by working with their
decimal equivalent
2. If the decimal sum is less than 16, write down
the hex equivalent
3. If the decimal sum is 16 or more, subtract 16,
write down the hex result in that column, and
carry 1 to the next-more-significant column

Arithmetic/Digital System/FIK/Dolly Indra/2015


Hex Digits with their Equivalent Binary and Decimal Value

Hexadecimal Binary Decimal Hexadecimal Binary Decimal

0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 A 1010 10
3 0011 3 B 1011 11
4 0100 4 C 1100 12
5 0101 5 D 1101 13
6 0110 6 E 1110 14
7 0111 7 F 1111 15

Arithmetic/Digital System/FIK/Dolly Indra/2015


Examples :
1. Add C + 9 in hex
2. Add 4F + 2D in hex

Arithmetic/Digital System/FIK/Dolly Indra/2015


Solution : 1
• Solution : C is equivalent to decimal 12, then
12 + 9 = 21

• Because 21 is greater than 16: the next step is


substract 21-16 = 5 and carry 1 to the next-
more-significant column. Therefore :
C+9 = 15(16)

Arithmetic/Digital System/FIK/Dolly Indra/2015


Solution : 2
• Add 4F + 2D in hex
4F
2D
---- +
• Solution : F & D are equivalent to decimal 15 & 13.
• Explanation : F+D = 15+13 = 28, substract 28-16= 12,
write down as C and carry 1 to 4+2+carry = 4+2+1 =
7. Therefore :
• 4F + 2D = 7C (16)

Arithmetic/Digital System/FIK/Dolly Indra/2015


Exercises :
• Perform the following decimal additions and
convert the original decimal members to
binary and add them.
1. 30 (10) + 25(10) = ----(2)
2. 17 (10) + 22(10) = ----(2)

Arithmetic/Digital System/FIK/Dolly Indra/2015


Exercises
• Convert these values to two’s complement
1. +18 (10) to two’s complement
2. -21(10) to two’s complement
3. -98(10) to two’s complement
• Performing hexadecimal addition
1. Add 7B + 3E in hex
2. Add 5A + F9 in hex
3. Add FF + D6 in hex
Arithmetic/Digital System/FIK/Dolly Indra/2015

You might also like