0% found this document useful (0 votes)
16 views

DCO Unit 2

Uploaded by

Likhitha B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

DCO Unit 2

Uploaded by

Likhitha B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Unit-2

Number Systems:

The number system is simply a system to represent or express


numbers. There are various types of number systems and the most
commonly used ones are decimal number system, binary number
system, octal number system, and hexadecimal number system.
Why is the Number System Important?
The number system helps to represent numbers in a small symbol set.
Computers, in general, use binary numbers 0 and 1 to keep the
calculations simple and to keep the amount of necessary circuitry less,
which results in the least amount of space, energy consumption and
cost.

Introduction:

Decimal, Binary, Octal and Hexadecimal. Inter- Conversions:

Binary Number System


The binary number system uses only two digits: 0 and 1. The numbers in this
system have a base of 2. Digits 0 and 1 are called bits and 8 bits together
make a byte. The data in computers is stored in terms of bits and bytes. The
binary number system does not deal with other numbers such as 2,3,4,5 and
so on. For example: 100012, 1111012, 10101012 are some examples of
numbers in the binary number system.

Octal Number System


The octal number system uses eight digits: 0,1,2,3,4,5,6 and 7 with the base
of 8. The advantage of this system is that it has lesser digits when compared
to several other systems, hence, there would be fewer computational errors.
Digits like 8 and 9 are not included in the octal number system. Just like the
binary, the octal number system is used in minicomputers but with digits from
0 to 7. For example, 358, 238, and 1418 are some examples of numbers in the
octal number system.
Decimal Number System
The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with the
base number as 10. The decimal number system is the system that we
generally use to represent numbers in real life. If any number is represented
without a base, it means that its base is 10. For example, 72310, 3210, and
425710 are some examples of numbers in the decimal number system.

Hexadecimal Number System


The hexadecimal number system uses sixteen digits/alphabets:
0,1,2,3,4,5,6,7,8,9 and A,B,C,D,E,F with the base number as 16. Here, A-F of
the hexadecimal system means the numbers 10-15 of the decimal number
system respectively. This system is used in computers to reduce the large-
sized strings of the binary system. For example, 7B316, 6F16, and 4B2A16 are
some examples of numbers in the hexadecimal number system.
Conversion of Number Systems
Steps for Conversion of Binary to Decimal Number
System
To convert a number from the binary to the decimal system, we use the
following steps.

 Step 1: Multiply each digit of the given number, starting


from the rightmost digit, with the exponents of the base.
 Step 2: The exponents should start with 0 and increase by
1 every time we move from right to left.
 Step 3: Simplify each of the above products and add them.

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.

Example: Convert 1001112 into the decimal 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.

100111 = (1 × 25) + (0 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20)

= (1 × 32) + (0 × 16) + (0 × 8) + (1 × 4) + (1 × 2) + (1 × 1)

= 32 + 0 + 0 + 4 + 2 + 1

= 39

Thus, 1001112 = 3910.

Conversion of Decimal Number System to Binary /


Octal / Hexadecimal Number System
To convert a number from the decimal number system to a
binary/octal/hexadecimal number system, we use the following steps. The
steps are shown on how to convert a number from the decimal system to the
octal system.

Example: Convert 432010 into the octal system.

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

Conversion from One Number System to Another


Number System
To convert a number from one of the binary/octal/hexadecimal systems to one
of the other systems, we first convert it into the decimal system, and then we
convert it to the required systems by using the above-mentioned processes.

Example: Convert 10101111002 to the hexadecimal system.

Solution:
Step 1: Convert this number to the decimal number system as explained in
the above process.

Thus, 10101111002 = 70010 → (1)

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:

Addition, Subtraction, Multiplication and Division In Binary Number


System:

What is Binary Addition?


Binary addition, unlike decimal addition, involves only two digits, i.e. 0 and 1.
Q2

What are the Rules of Binary Addition?


There are four rules of binary addition which are:

 0+0=0
 0+1=1
 1+0=1
 1+1=10
There are four rules for binary addition:

How To Do Binary Addition?


Now, look at the example of the binary addition:101 + 101

Procedure for Binary Addition of Numbers:

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

So, the resultant of the addition operation is 1010.

There are four rules for binary subtraction:


How to Subtract Binary Numbers?
Learn how to do binary subtraction using the example: 1010 – 101

Procedure to do Binary Subtraction:


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

——————

Step 3: So, subtract the value in the 10’s place, ( 0 – 0 ) = 0.

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

So, the resultant of the subtraction operation is 0101.


There are four rules for binary multiplication:

Multiplication is always 0, whenever at least one input is 0.

3. There are four parts in any division: Dividend, Divisor,


quotient, and remainder.
The result is always not defined, whenever the divisor is 0.

1’s and 2’s Complement Method in Binary Number System:

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

N' is used to show the -N in 1's complement notation

N is used to show the positive integer

n is used to show the number of bits per word

For example:

Suppose we have 8 bit word, and N = 6. Now the 1's complement of N is


described as follows:

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.

1. 2's complement of binary number 5 (0101) is binary number 11 (1011)


2. 1's complement of binary number 13 (1101) is binary number 3 (0011)

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

N* is used to show the -N in 1's complement notation

N is used to show the positive integer

n is used to show the number of bits per word

For example:

Suppose we have 8 bit word, and N = 6. Now the 1's complement of N is


described as follows:

N* = 28 - 6

= 250

= (11111010)2

With the help of this formula, we can convert the given number into the 2's
complement.

Subtraction Using 1’s and 2’s Compliment:

Weighted Number System:

The positional number system is also known as weighted number


system. In such a system, a number is represented by a string of digits where each digit position
has an associated weight. The value of a number is a weighted sum of the digits.

 Example 1: 1734 = (1 x 1000) + (7 x 100) + (3 x 10) + (4 x 1)


 Example 2: 568.23 = (5 x 100) + (6 x 10) + (8 x 1) + (2 x 0.1) + (3 x 0.01)

In general, a number D of the form d1d0.d-1d-2 has the value


D = d1 x 101+ d0 x 100 + d-1 x 10-1 + d-2 x 10-2

Here 10 is called the radix or base.

Q1. Express the decimal number 106.58 as a sum of the values of each digit.

Answer: 106.58 = 1×10 +0x10 +6×10 +5×10 +8×10 =1×100+0x10+6×1+5×0.1+8×0.01


2 1 0 -1 -2

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

Binary Coded Decimal (BCD):

Binary Coded Decimal, or BCD, is another process for converting decimal


numbers into their binary equivalents.

 It is a form of binary encoding where each digit in a decimal number is


represented in the form of bits.
 This encoding can be done in either 4-bit or 8-bit (usually 4-bit is
preferred).
 It is a fast and efficient system that converts the decimal numbers into
binary numbers as compared to the existing binary system.
 These are generally used in digital displays where is the manipulation of
data is quite a task.
 Thus BCD plays an important role here because the manipulation is done
treating each digit as a separate single sub-circuit.
The BCD equivalent of a decimal number is written by replacing each
decimal digit in the integer and fractional parts with its four
bit binary equivalent.the BCD code is more precisely known as 8421 BCD
code
Truth Table for Binary Coded Decimal

DECIMAL NUMBER BCD

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

8 1000

9 1001

In the BCD numbering system, the given decimal number is segregated


into chunks of four bits for each decimal digit within the number. Each
decimal digit is converted into its direct binary form (usually represented in 4-
bits).
For example:

1. Convert (123)10 in BCD


From the truth table above,
1 -> 0001
2 -> 0010
3 -> 0011
thus, BCD becomes -> 0001 0010 0011
2. Convert (324)10 in BCD
(324)10 -> 0011 0010 0100 (BCD)
Again from the truth table above,
3 -> 0011
2 -> 0010
4 -> 0100
thus, BCD becomes -> 0011 0010 0100

Addition of BCD Numbers:

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 −

 Step 1 − Perform addition of two BCD numbers by following the rules of


binary addition.
 Step 2 − If the result or sum is a 4-bit binary number which is less than
or equal to 9, then the sum is a valid BCD number.
 Step 3 − If the sum is a 4-bit number that is greater than 9 or if a carry is
generated, then it is an invalid sum.
 Step 4 − To obtain the corrected result/sum, add 6 (0110) to the 4-bit
invalid sum. If a carry is generated when 6 is added, then propagate and
add this carry to the next 4-bit group. This step is done to skip the six
illegal BCD codes (i.e. 1010, 1011, 1100, 1101, 1110, and 1111).

Explore our latest online courses and learn new skills at your own pace. Enroll
and become a certified expert to boost your career.

Rules of Binary Addition

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

Perform the addition 30 + 15 in BCD scheme.

Solution − Given decimal numbers and their equivalent BCD representation is,

(30)10 = (0011 0000)BCD

(15)10 = (0001 0101)BCD

The BCD addition of the given numbers is as below −

30 0011 0000

+ 15 + 0001 0101

45 0100 0101

Non-Weighted Number System:


Non-positional number system is also known as non-weighted number
system.

Applications: The number system helps us in identifying the extent to


which we need to limit an entity. These give us a general insight into
the mathematical operations regarding the given numbers. This helps
in the calculation of numbers using mathematical operations.
It is clear that numbers are used to represent a certain quantity. When
certain symbols or digits are used to represent the numbers themselves, it
forms a number system. Hence, a number system is such a system as can
be used to define a set of values, which are further used to represent a
quantity.
Excess-3 CODE:

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:

1. We find the decimal number of the given binary number.


2. Then we add 3 in each digit of the decimal number.
3. Now, we find the binary code of each digit of the newly generated
decimal number.

The Excess-3 code for the decimal number is as follows:

Decimal Digit BCD Code Excess-3 Code

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.

Example 1: Decimal number 31


1. We find the BCD code of each digit of the decimal number.

Digit BCD

3 0011

1 0001

2) Then, we add 0011 in both of the BCD code.

Decimal BCD Excess-3


3 0011+00 0110
11

1 0001+00 0100
11

3. So, the excess-3 code of the decimal number 31 is 0110 0100

Example 2: Decimal number 81.61


1. We find the BCD code of each digit of the decimal number.

Digit BCD

8 1000

1 0001

6 0110

1 0001

2) Then, we add 0011 in both of the BCD code.

Decima BCD Excess-3


l

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

Why use Excess-3 code?

There are the following advantages of excess-3 code which make it required
to use:

1. These codes are self-complementary.


2. These codes use biased representation.
3. The excess-3 code has no limitation, so that it considerably simplifies
arithmetic operations.
4. The codes 0000 and 1111 can cause a fault in the transmission line. The
excess-3 code doesn't use these codes and gives an advantage for memory
organization.
5. These codes are usually unweighted binary decimal codes.
6. This code has a vital role in arithmetic operations. It is because it resolves
deficiencies which are encountered when we use the 8421 BCD code for
adding two decimal digits whose sum is greater than 9.

Gray Code Conversions:

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.

Gray and Binary Codes:


Binary to Gray conversion :
1. The Most Significant Bit (MSB) of the gray code is always equal to the
MSB of the given binary code.
2. Other bits of the output gray code can be obtained by XORing binary code
bit at that index and previous index.
Gray to 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.

You might also like