Вы находитесь на странице: 1из 15

PRINCIPLES OF DIGITAL TECHNIQUES

NUMBER SYSTEM
Many number systems are in use in digital technology. The most common are the decimal, binary, octal, and hexadecimal systems. The decimal system is clearly the most familiar to us because it is a tool that we use every day. Examining some of its characteristics will help us to better understand the other systems. In the next few pages we shall introduce four numerical representation systems that are used in the digital system. There are other systems, which we will look at briefly.

Decimal Binary Octal Hexadecimal

1.

Decimal System
The decimal system is composed of 10 numerals or symbols. These 10 symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Using these symbols as digits of a number, we can express any quantity. The decimal system is also called the base-10 system because it has 10 digits Even though the decimal system has only 10 symbols, any number of any magnitude can be expressed by using our system of positional weighting.

Decimal Examples

3.1410 5210 102410 6400010

2.

Binary System

In the binary system, there are only two symbols or possible digit values, 0 and 1. This base-2 system can be used to represent any quantity that can be represented in decimal or other base system. Binary Counting The Binary counting sequence is shown in the table: 3 2 22 21 20 Decimal 0 0 0 0 0 0 0 0 1 1 0 0 1 0 2 0 0 1 1 3 0 1 0 0 4
JUNED SIDDIQUE Page 1

PRINCIPLES OF DIGITAL TECHNIQUES

0 0 0 1 1 1 1 1 1 1 1

1 1 1 0 0 0 0 1 1 1 1

0 1 1 0 0 1 1 0 0 1 1

1 0 1 0 1 0 1 0 1 0 1

5 6 7 8 9 10 11 12 13 14 15

3.

Octal System

The octal number system has a base of eight, meaning that it has eight possible digits: 0,1,2,3,4,5,6,7.

4.

Hexadecimal System

The hexadecimal system uses base 16. Thus, it has 16 possible digit symbols. It uses the digits 0 through 9 plus the letters A, B, C, D, E, and F as the 16 digit symbols.

Binary(2) 0 1

Octal(8) 0 1 2 3 4 5 6 7

Decimal(10) 0 1 2 3 4 5 6 7 8 9

Hexadecimal(16) 0 1 2 3 4 5 6 7 8 9 A B C D E F

JUNED SIDDIQUE

Page 2

PRINCIPLES OF DIGITAL TECHNIQUES

CODE CONVERSION
Converting from one code form to another code form is called code conversion, like converting from binary to decimal or converting from hexadecimal to decimal.

Binary-To-Decimal Conversion
Any binary number can be converted to its decimal equivalent simply by summing together the weights of the various positions in the binary number which contain a 1.

Binary 110112 24+23+01+21+20 Result And Binary 101101012 27+06+25+24+03+22+01+20 Result

Decimal =16+8+0+2+1 2710

Decimal =128+0+32+16+0+4+0+1 18110

Decimal-To-Binary Conversion
There are 2 methods:

Reverse of Binary-To-Decimal Method Repeat Division

Reverse of Binary-To-Decimal Method Decimal 4510 Result

Binary =32 + 0 + 8 + 4 +0 + 1 =25+0+23+22+0+20 =1011012

JUNED SIDDIQUE

Page 3

PRINCIPLES OF DIGITAL TECHNIQUES

Repeat Division-Convert decimal to binary This method uses repeated division by 2. Convert 2510 to binary Division 25/2 12/2 6/2 3/2 1/2 Result Remainder = 12+ remainder of 1 = 6 + remainder of 0 = 3 + remainder of 0 = 1 + remainder of 1 = 0 + remainder of 1 2510 Binary 1 (Least Significant Bit) 0 0 1 1 (Most Significant Bit) = 110012

Binary-To-Octal / Octal-To-Binary Conversion


Octal Digit 0 Binary Equivalent 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111

Each Octal digit is represented by three binary digits. Example: 100 111 0102 = (100) (111) (010)2 = 4 7 28

Repeat Division-Convert decimal to octal


This method uses repeated division by 8. Example: Convert 17710 to octal and binary Division 177/8 22/ 8 2/8 Result Binary Result = 22+ remainder of 1 = 2 + remainder of 6 = 0 + remainder of 2 17710 Binary 1 (Least Significant Bit) 6 2 (Most Significant Bit) = 2618 = 0101100012

JUNED SIDDIQUE

Page 4

PRINCIPLES OF DIGITAL TECHNIQUES

Hexadecimal to Decimal/Decimal to Hexadecimal Conversion


Example: 2AF16 = 2 x (162) + 10 x (161) + 15 x (160) = 68710

Repeat Division- Convert decimal to hexadecimal This method uses repeated division by 16. Example: convert 37810 to hexadecimal and binary Division 378/16 23/16 1/16 Result Binary Result = 23+ remainder of 10 = 1 + remainder of 7 = 0 + remainder of 1 37810 Hexadecimal A (Least Significant Bit) 7 1 (Most Significant Bit) = 17A16 = 0001 0111 10102

Binary-To-Hexadecimal /Hexadecimal-To-Binary Conversion


Hexadecimal Digit Binary Equivalent Hexadecimal Digit Binary Equivalent 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 C 1100 5 0101 D 1101 6 0110 E 1110 7 0111 F 1111

Each Hexadecimal digit is represented by four bits of binary digit. Example: 1011 0010 11112 = (1011) (0010) (1111)2 = B 2 F16

Octal-To-Hexadecimal Hexadecimal-To-Octal Conversion


Convert Octal (Hexadecimal) to Binary first. Regroup the binary number by three bits per group starting from LSB if Octal is required. Regroup the binary number by four bits per group starting from LSB if Hexadecimal is required.

JUNED SIDDIQUE

Page 5

PRINCIPLES OF DIGITAL TECHNIQUES

Example: Convert 5A816 to Octal. Hexadecimal 5A816 Result Binary/Octal = 0101 1010 1000 (Binary) = 010 110 101 000 (Binary) = 2 6 5 0 (Octal)

JUNED SIDDIQUE

Page 6

PRINCIPLES OF DIGITAL TECHNIQUES

Binary Arithmetic
The arithmetic operations - addition, subtraction, multiplication and division, performed on the binary numbers is called binary arithmetic. In computer systems, the basic arithmetic operations performed on the binary numbers is Binary Addition, and Binary Subtraction, In the following subsections, we discuss the binary addition and the binary subtraction operations.

Binary Addition
Binary addition involves adding of two or more binary numbers. The binary addition rules are used while performing the binary addition. Table 1 shows the binary addition rules.
Table 1 Binary Addition Rules

Input 1 0 0 1 1

Input 2 0 1 0 1

Sum 0 1 1 0

Carry No carry No carry No carry 1

Binary addition of three inputs, when all the inputs are 1, follows the rule shown in Table 2. Binary addition of three inputs Input 1 1 Input 2 1 Input 3 1 Sum 1 Carry 1

Addition of the binary numbers involves the following steps1. Start addition by adding the bits in unit column (the rightmost column). Use the rules of binary addition. 2. The result of adding bits of a column is a sum with or without a carry. 3. Write the sum in the result of that column. 4. If carry is present, the carry is carried-over to the addition of the next left column.
5.

Repeat steps 2-4 for each column, i.e., the tens column, hundreds column and so on.

JUNED SIDDIQUE

Page 7

PRINCIPLES OF DIGITAL TECHNIQUES Example 1. Add 10 and 01. Verify the answer with the help of decimal addition. When we add 0 and 1 in the unit column, sum is 1 and there is no carry. The sum 1 is written in the unit column of the result. In the tens column, we add 1 and 0 to get the sum 1. There is no carry. The sum 1 is written in the tens column of the result.

Example 2. Add 01 and 11. Verify the answer with the help of decimal addition. When we add 1 and 1 in the unit column, sum is 0 and carry is 1. The sum 0 is written in the unit column of the result. The carry is carried-over to the next column, i.e. the tens column. In the tens column, we add 0, 1 and the carried-over 1, to get sum 0 and carry 1. The sum 0 is written in the tens column of the result. The carry 1 is carried-over to the hundreds column. In the hundreds column, the result is 1.

Example 3. Add 10111, 11100 and 11. Verify the answer with the help of decimal addition

JUNED SIDDIQUE

Page 8

PRINCIPLES OF DIGITAL TECHNIQUES

Binary Subtraction
Binary subtraction involves subtracting of two binary numbers. The binary subtraction rules are used while performing the binary subtraction. The binary subtraction rules are shown in Table

The steps for performing subtraction of the binary numbers are as follows1. Start subtraction by subtracting the bit in the lower row from the upper row, in the unit column. 2. Use the binary subtraction rules. If the bit in the upper row is less than lower row, borrow 1 from the upper row of the next column (on the left side). The result of subtracting two bits is the difference. 3. Write the difference in the result of that column. 4. Repeat step 2-3 for each column, i.e., the tens column, hundreds column and so on. Example 1. Subtract 01 from 11. Verify the answer with the help of decimal subtraction. When we subtract 1 from 1 in the unit column, the difference is 0. Write the difference in the unit column of the result. In the tens column, subtract 0 from 1 to get the difference 1. Write the difference in the tens column of the result.

Example 2. Subtract 10010 from 10101. Verify the answer with the help of decimal subtraction.

JUNED SIDDIQUE

Page 9

PRINCIPLES OF DIGITAL TECHNIQUES

Complement of Binary Numbers


Complements are used in computer for the simplification of the subtraction operation. We now see, how to find the complement of a binary number. There are two types of complements for the binary number system 1s complement and 2s complement. 1s complement of Binary number is computed by changing the bits 1 to 0 and the bits 0 to 1. For example, 1s complement of 110 is 001 1s complement of 1011 is 0100 1s complement of 1101111 is 0010000 2s complement of Binary number is computed by adding 1 to the 1s complement of the binary number. For example, 2s complement of 110 is 001 + 1 = 010 2s complement of 1011 is 0100 + 1 = 0101 2s complement of 1101111 is 0010000 + 1 = 0010001

Binary Subtraction using 1s and 2s complement


From calss notes

Binary multiplication
It is actually much simpler than decimal multiplication. In the case of decimal multiplication, we need to remember 3 x 9 = 27, 7 x 8 = 56, and so on. In binary multiplication, we only need to remember the following, 0x0=0 0x1=0 1x0=0 1x1=1 Note that since binary operates in base 2, the multiplication rules we need to remember are those that involve 0 and 1 only. As an example of binary multiplication we have 101 times 11, 101 x11 First we multiply 101 by 1, which produces 101. Then we put a 0 as a placeholder as we would in decimal multiplication, and multiply 101 by 1, which produces 101.

JUNED SIDDIQUE

Page 10

PRINCIPLES OF DIGITAL TECHNIQUES

101 x11 101 1010 <-- the 0 here is the placeholder The next step, as with decimal multiplication, is to add. The results from our previous step indicates that we must add 101 and 1010, the sum of which is 1111. 101 x11 101 1010 1111

Binary division
It is almost as easy, and involves our knowledge of binary multiplication. Take for example the division of 1011 into 11.

11 R=10 11 )1011 -11 101 -11 10 <-- remainder, R To check our answer, we first multiply our divisor 11 by our quotient 11. Then we add its' product to the remainder 10, and compare it to our dividend of 1011. 11 x 11 11 11 1001 <-- product of 11 and 11 1001 + 10 1011 <-- sum of product and remainder The sum is equal to our initial dividend, therefore our solution is correct.

JUNED SIDDIQUE

Page 11

PRINCIPLES OF DIGITAL TECHNIQUES

CODES
Binary Codes
Binary codes are codes which are represented in binary system with modification from the original ones. Below we will be seeing the following

Weighted Binary Systems Non Weighted Codes

Weighted Binary Systems


Weighted binary codes are those which obey the positional weighting principles, each position of the number represents a specific weight. The binary counting sequence is an example. Decimal 0 1 2 3 4 5 6 7 8 9 8421 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 2421 0000 0001 0010 0011 0100 1011 1100 1101 1110 1111 5211 0000 0001 0011 0101 0111 1000 1010 1100 1110 1111 Excess-3 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100

8421 Code/BCD Code The BCD (Binary Coded Decimal) is a straight assignment of the binary equivalent. It is possible to assign weights to the binary bits according to their positions. The weights in the BCD code are 8,4,2,1. Example: The bit assignment 1001, can be seen by its weights to represent the decimal 9 because: 1x8+0x4+0x2+1x1 = 9

JUNED SIDDIQUE

Page 12

PRINCIPLES OF DIGITAL TECHNIQUES

2421 Code This is a weighted code, its weights are 2, 4, 2 and 1. A decimal number is represented in 4-bit form and the total four bits weight is 2 + 4 + 2 + 1 = 9. Hence the 2421 code represents the decimal numbers from 0 to 9. 5211 Code This is a weighted code, its weights are 5, 2, 1 and 1. A decimal number is represented in 4-bit form and the total four bits weight is 5 + 2 + 1 + 1 = 9. Hence the 5211 code represents the decimal numbers from 0 to 9.

Non Weighted Codes


Non weighted codes are codes that are not positionally weighted. That is, each position within the binary number is not assigned a fixed value. Excess-3 Code Excess-3 is a non weighted code used to express decimal numbers. The code derives its name from the fact that each binary code is the corresponding 8421 code plus 0011(3). Example: 1000 of 8421 = 1011 in Excess-3 Gray Code The gray code belongs to a class of codes called minimum change codes, in which only one bit in the code changes when moving from one code to the next. The Gray code is nonweighted code, as the position of bit does not contain any weight. The gray code is a reflective digital code which has the special property that any two subsequent numbers codes differ by only one bit. This is also called a unit-distance code. In digital Gray code has got a special place. Decimal Number 0 1 2 3 4 5 6 7 8 9 10 11 12
JUNED SIDDIQUE

Binary Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100

Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010
Page 13

PRINCIPLES OF DIGITAL TECHNIQUES

13 14 15

1101 1110 1111

1011 1001 1000

BCD addition
In BCD addition of two numbers involve following rules:-

1. Maximum value of the sum for two digits = 9 (max digit 1) + 9 (max digit 2) + 1 (previous addition carry) = 19 2. If sum of two BCD digits is less than or equal to 9 (1001) without carry then the result is a correct BCD number. 3. If sum of two BCD digits is greater than or equal to 10 (1010) the result is in-correct BCD number. Perform steps 4 for correct BCD sum. 4. Add 6 (0110) to the result. Example: Add 599 and 984 using BCD numbers

JUNED SIDDIQUE

Page 14

PRINCIPLES OF DIGITAL TECHNIQUES

JUNED SIDDIQUE

Page 15

Вам также может понравиться