Digital lecture 2
Digital lecture 2
1-Arithmetic Operation:
Binary arithmetic is much simpler than decimal arithmetic because here
only two digits 0&1 are involved. Arithmetic operations in a computer are
done in its arithmetic unit by using binary numbers. The basic arithmetic
operations are, addition, subtraction, multiplication, division.
These operations are performed by digital logic circuits called the adder,
subtractor, multiplier and divider.
The arithmetic rules for Addition, Subtraction, Multiplication, and
Division of binary numbers are given below:
1-1 Binary Addition: The four basic rules for adding binary digits (bits) are
as follows.
0+0=0 Sum of 0 with a carry 0
0+1=1 Sum of 1 with a carry 0
1+0=1 Sum of 1 with a carry 0
1+1=1 0 Sum of 0 with a carry 1
Ex3: 1111
+1100
11011
1-2 Binary Subtraction: The four basic rules for subtracting are as
follows.
0-0=0
1-1=0
1-0=1
1
Prepared by: Dana S. Abdullah Digital 2nd Lecture
Ex3: 101101
-001110
011111
1-3 Binary Multiplication & Division: We follow the same rule of decimal
numbers.
2-Complement Representations:
2-1: 1’s complement and 2’s complement:
2
Prepared by: Dana S. Abdullah Digital 2nd Lecture
For Example
Find the 2’s complement of 10110
1’s complement of 10110= 01001
For obtaining 2’s complement of 10110, you have to add 1 to 01001(1’s
complement of 10110)
i.e, 1+ 01001= 01010
3
Prepared by: Dana S. Abdullah Digital 2nd Lecture
Solution:
The answer is –ve, since no carry is obtained. Then the answer is the 1’s
complement of the 01100 and is in opposite sign i.e, -10011
4
Prepared by: Dana S. Abdullah Digital 2nd Lecture
Solution:
Ex1:
Find the 9’scomplement of each of the following decimal numbers.
a) 15 b)135
Solution: Subtract each digit in the number from 9 to get the 9’s
complement
a) 99 – 15 = 84 (9’s complement of 15)
b) 999 – 135 = 864 (9’s complement of 135)
5
Prepared by: Dana S. Abdullah Digital 2nd Lecture
But the 10’s complement of a decimal no. is equal to its 9’s complement + 1.
Ex2:
Convert the following decimal number into its 10’s complement form
a) 18 b) 152
Solution:
a) 99-18= 81 (9’s complement of 18)
81+1= 82(10’s complement of 18)
b) 999-152= 847 (9’s complement of 152)
847+1 = 848 (10’s complement of 152)
2.2.1: Subtraction using 9’s complement
Subtraction of a smaller number from a larger number using 9’s complement
Steps:
• Take the 9’s complement of the subtrahend
• Carry indicates that the answer is positive. Add the carry to the list
significant digit
6
Prepared by: Dana S. Abdullah Digital 2nd Lecture
7
Prepared by: Dana S. Abdullah Digital 2nd Lecture
3- Codes
We are very comfortable with the decimal number system, but digital
systems like computers & other digital circuits process the data in the binary
format. So, various binary codes are used to represent the data.
In this section three types of codes are identified.
3-1 BCD (Binary Coded Decimal):
A Binary Coded Decimal (BCD) is one in which, decimal digits are encoded
by their natural binary equivalents-one at a time-into groups of four bits.
For example (25)10is represented by [0010 0101] using BCD code, rather
than (11001)2. It is a positional weight code. Each position of a number
represents a specific weight.
These codes are also known as 8421 code or simply BCD code. The
number 8421 indicates the binary weights of the four bits. i.e. the weights of
the first (right most) position is 20 =1, 21 =2, 22 =4, 23 =8. Replacing from
left to right, the weights are 8-4-2-1,and hence it is called 8421 code.
8
Prepared by: Dana S. Abdullah Digital 2nd Lecture
9
Prepared by: Dana S. Abdullah Digital 2nd Lecture
10
Prepared by: Dana S. Abdullah Digital 2nd Lecture
So, Gray code can be determined for each binary number. The
following table shows the Binary number and its Gray code for
decimal numbers.
11
Prepared by: Dana S. Abdullah Digital 2nd Lecture
12
Prepared by: Dana S. Abdullah Digital 2nd Lecture
13