DCO Unit 2
DCO Unit 2
Number Systems:
Introduction:
Let us understand the steps with the help of the following example in which
we need to convert a number from binary to decimal number system.
Solution:
Step 1: Identify the base of the given number. Here, the base of 1001112 is 2.
Step 2: Multiply each digit of the given number, starting from the rightmost
digit, with the exponents of the base. The exponents should start with 0 and
increase by 1 every time as we move from right to left. Since the base is 2
here, we multiply the digits of the given number by 20, 21, 22 , and so on from
right to left.
Step 3: We just simplify each of the above products and add them.
Here, the sum is the equivalent number in the decimal number system of the
given number. Or, we can use the following steps to make this process
simplified.
= (1 × 32) + (0 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (1 × 1)
= 32 + 0 + 0 + 4 + 2 + 1
= 39
Solution:
Step 1: Identify the base of the required number. Since we have to convert
the given number into the octal system, the base of the required number is 8.
Step 2: Divide the given number by the base of the required number and note
down the quotient and the remainder in the quotient-remainder form. Repeat
this process (dividing the quotient again by the base) until we get the quotient
less than the base.
Step 3: The given number in the octal number system is obtained just by
reading all the remainders and the last quotient from bottom to top.
Therefore, 432010 = 103408
Solution:
Step 1: Convert this number to the decimal number system as explained in
the above process.
Step 2: Convert the above number (which is in the decimal system), into the
required number system (hexadecimal).
Here, we have to convert 70010 into the hexadecimal system using the above-
mentioned process. It should be noted that in the hexadecimal system, the
numbers 11 and 12 are written as B and C respectively.
Thus, 70010 = 2BC16 → (2)
From the equations (1) and (2), 10101111002 = 2BC16
conversion of binary number system to decimal number system:
0+0=0
0+1=1
1+0=1
1+1=10
There are four rules for binary addition:
101
(+) 101
Step 1: First consider the 1’s column, and add the one’s column,( 1+1 ) and it gives the
result 10 as per the condition of binary addition.
Step 2: Now, leave the 0 in the one’s column and carry the value 1 to the 10’s column.
1
101
(+) 101
————–
Step 3: Now add 10’s place, 1+( 0 + 0 ) = 1. So, nothing carries to the 100’s place and
leave the value 1 in the 10’s place
101
(+) 101
————-
10
Step 4: Now add the 100’s place ( 1 + 1 ) = 10. Leave the value 0 in the 100’s place and
carries 1 to the 1000’s place.
101
(+) 101
————-
1010
(-) 101
Step 1: First consider the 1’s column, and subtract the one’s column,( 0 – 1 )
and it gives the result 1 as per the condition of binary subtraction with a
borrow of 1 from the 10’s place.
Step 2: After borrowing 1 from the 10’s column, the value 1 in the 10’s column
is changed into the value 0
1 Borrow
1010
(-) 1 0 1
——————
1 Borrow
1010
(-) 1 0 1
——————
01
Step 4: Now subtract the values in 100’s place. Borrow 1 from the 1000’s
place ( 0 – 1 ) = 1.
1 1 Borrow
1010
(-) 1 0 1
——————
0101
Complements
In order to perform the logical manipulation and to simplify the subtraction
operation, the digital systems generally use complements. The binary
number system contains two types of complements, i.e., 1's complement
and 2's complement. Now we will describe each complement individually.
After that, we will describe the difference between them.
1's Complement
The binary numbers can be easily converted into the 1's complement with
the help of a simple algorithm. According to this algorithm, if we toggle or
invert all bits of a binary number, the generated binary number will become
the 1's complement of that binary number. That means we have to transform
1 bit into the 0 bit and 0 bit into the 1 bit in the 1's complement. N' is used to
indicate the 1's complement of a number.
Example: Here, we will assume that the number is stored with the help of 4
bits.
1. 1's complement of binary number 5 (0101) is binary number 10 (1010)
2. 1's complement of binary number 13 (1101) is binary number 2 (0010)
There is another way to find the 1's complement of a number. We can use a
formula to find it, which is described as follows:
N' = (2n - 1) - N
Where
For example:
N' = (28 - 1) - 6
= 249
= (11111001)2
With the help of this formula, we can convert the given number into the 1's
complement.
2's Complement
The binary numbers can also be easily converted into the 2's complement
with the help of a very simple algorithm. According to this algorithm, we can
get the 2's complement of a binary number by first inverting the given
number. After that, we have to add 1into the LSB (least significant bit). That
means we have to first perform 1's complement of a number, and then we
have to add 1 into that number to get the 2's complement. N* is used to
show the 2's complement of a number.
Example: Here, we will assume that the number is stored with the help of 4
bits.
There is another way to find the 2's complement of a number. We can use a
formula to find it, which is described as follows:
N* = 2n - N
Where
For example:
N* = 28 - 6
= 250
= (11111010)2
With the help of this formula, we can convert the given number into the 2's
complement.
Q1. Express the decimal number 106.58 as a sum of the values of each digit.
Q2. What weight does the digit 7 have in each of the following numbers?
a. 1370 – Ans. 10
b. 6725 – Ans. 100
c. 7051 – Ans. 1000
d. 58.72 – Ans. 0.1
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Binary coded decimal addition follows the rules of binary arithmetic, however
there are some extra things that require to be taken care of. The BCD addition
of two BCD numbers is performed as per the following steps −
Explore our latest online courses and learn new skills at your own pace. Enroll
and become a certified expert to boost your career.
The following are the rules used to perform binary addition of two binary digits
−
First Bit Second Bit Result
0 0 0 + 0 = 0; no carry
0 1 0 + 1 = 1; no carry
1 0 1 + 0 = 1; no carry
1 1 1 + 1 = 0; carry = 1
After getting the knowledge of BCD addition and rules of binary addition, let us
now consider some solved examples to understand the BCD addition in detail.
Example 1
Solution − Given decimal numbers and their equivalent BCD representation is,
30 0011 0000
+ 15 + 0001 0101
45 0100 0101
The excess-3 code is also treated as XS-3 code. The excess-3 code is a non-
weighted and self-complementary BCD code used to represent the decimal
numbers. This code has a biased representation. This code plays an
important role in arithmetic operations.
We can find the excess-3 code of the given binary number by using the
following steps:
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
In excess-3 code, the codes 1111 and 0000 are never used for any decimal
digit. Let's take some examples of Excess-3 code.
Digit BCD
3 0011
1 0001
1 0001+00 0100
11
Digit BCD
8 1000
1 0001
6 0110
1 0001
8 1000+00 1011
11
1 0001+00 0100
11
6 0110+00 1001
11
3) So, the excess-3 code of the decimal number 81.61 is 1011 0100.1001
0100
There are the following advantages of excess-3 code which make it required
to use:
Gray Code:
Gray code is a binary numeral system where two successive values differ in only one bit. This
code was invented by Frank Gray in 1953. The Gray Code is a sequence of binary
number systems, which is also known as reflected binary code.
1. The Most Significant Bit (MSB) of the binary code is always equal to the
MSB of the given gray code.
2. Other bits of the output binary code can be obtained by checking the gray
code bit at that index. If the current gray code bit is 0, then copy the
previous binary code bit, else copy the invert of the previous binary code
bit.