Number System
Number System
Number System
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.
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
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
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
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.
Decimal-To-Binary Conversion
There are 2 methods:
JUNED SIDDIQUE
Page 3
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
Each Octal digit is represented by three binary digits. Example: 100 111 0102 = (100) (111) (010)2 = 4 7 28
JUNED SIDDIQUE
Page 4
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
Each Hexadecimal digit is represented by four bits of binary digit. Example: 1011 0010 11112 = (1011) (0010) (1111)2 = B 2 F16
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
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
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
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
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
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
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
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
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
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.
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
13 14 15
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
JUNED SIDDIQUE
Page 15