Dr. I. Manimehan, Department of Physics, MRGAC Page 1 NUMBER SYSTEM A digital computer is a programmable machine that processes binary data, i.e., data represented in binary number system. We have to understand computers and digital electronics only with the help of binary number system. But we are used to decimal number system in our everyday life for a long period of time and we take the rules for granted. 1.1 DECIMAL NUMBER SYSTEM The decimal number system makes use of ten digits namely, 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Since ten basic symbols or digits are used, the decimal number system is said to have a base or radix of ten. When we want to express numbers of value greater than 9, we use two or more digits and the position of each digit within the number gives us the magnitude it represents. All the digits in the decimal system are expressed in powers of 10 like 10 0 , 10 1 , 10 2 etc., for the integer part and 10 −1 , 10 −2 , 10 −3 etc., for the fractional part. The integer portion and fractional portion in a decimal portion in a decimal number system are separated by a decimal point. The quantities 10 0 , 10 1 , 10 2 etc., simply represent the units, tens, hundreds etc and the quantities 10 −1 , 10 −2 , 10 −3 etc., represent one tenth, one hundredth, one thousandth etc. The quantities 10 2 , 10 1 , 10 0 , 10 −1 , 10 −2 , 10 −3 etc., are called weights. i) 25 = 20 + 5 = 2 x 10 + 5 x 1 = 2 x10 1 + 5 x10 0 The digit 2 has a weight 10 and the digit 5 has a weight 1. ii) 7694 = 7000 + 600 + 90 + 4 = 7x1000 + 6x100 + 9x10 + 4x1 = 7x10 3 + 6x10 2 + 9x10 1 + 4x10 0 The digit 7 has a weight 1000, digit 6 has a weight 100, the digit 9 has a weight 10 and the digit 4 has a weight 1. 1.2 BINARY NUMBER SYSTEM A binary number system uses only two symbols or digits namely, 0 and 1. That is the binary number system has a base or radix of 2. A binary 0 or 1 is often called a bit. All the bits will have powers of 2 like 2 0 , 2 1 , 2 2 , etc., for the integer portion and 2 −1 , 2 −2 , 2 −3 , etc., for the fractional portion. Here we have a binary point in a binary number system. A 4-bit binary word is called as a nibble. An 8-bit binary word is called as a byte. A 16- bit binary word is simply called as a word and a 32-bit binary word is called as double word.
27
Embed
1.1 DECIMAL NUMBER SYSTEM The decimal number system …
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Dr. I. Manimehan, Department of Physics, MRGAC Page 1
NUMBER SYSTEM
A digital computer is a programmable machine that processes binary data, i.e., data
represented in binary number system. We have to understand computers and digital electronics
only with the help of binary number system. But we are used to decimal number system in our
everyday life for a long period of time and we take the rules for granted.
1.1 DECIMAL NUMBER SYSTEM
The decimal number system makes use of ten digits namely, 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
Since ten basic symbols or digits are used, the decimal number system is said to have a base or
radix of ten. When we want to express numbers of value greater than 9, we use two or more
digits and the position of each digit within the number gives us the magnitude it represents. All
the digits in the decimal system are expressed in powers of 10 like 100, 101, 102 etc., for the
integer part and 10−1, 10−2, 10−3 etc., for the fractional part. The integer portion and fractional
portion in a decimal portion in a decimal number system are separated by a decimal point.
The quantities 100, 101, 102 etc., simply represent the units, tens, hundreds etc and the
quantities 10−1, 10−2, 10−3 etc., represent one tenth, one hundredth, one thousandth etc. The
quantities 102, 101, 100, 10−1, 10−2, 10−3 etc., are called weights.
i) 25 = 20 + 5
= 2 x 10 + 5 x 1
= 2 x101 + 5 x100
The digit 2 has a weight 10 and the digit 5 has a weight 1.
ii) 7694 = 7000 + 600 + 90 + 4
= 7x1000 + 6x100 + 9x10 + 4x1
= 7x103 + 6x102 + 9x101 + 4x100
The digit 7 has a weight 1000, digit 6 has a weight 100, the digit 9 has a weight 10 and the digit
4 has a weight 1.
1.2 BINARY NUMBER SYSTEM
A binary number system uses only two symbols or digits namely, 0 and 1. That is the
binary number system has a base or radix of 2. A binary 0 or 1 is often called a bit. All the bits
will have powers of 2 like 20, 21, 22, etc., for the integer portion and 2−1, 2−2, 2−3, etc., for the
fractional portion. Here we have a binary point in a binary number system.
A 4-bit binary word is called as a nibble. An 8-bit binary word is called as a byte. A 16-
bit binary word is simply called as a word and a 32-bit binary word is called as double word.
Dr. I. Manimehan, Department of Physics, MRGAC Page 2
1.3 BINARY TO DECIMAL CONVERSION
A binary number can be converted into a decimal number by adding the products of each
bit and its weight. Let us take a few examples
i) 1 0 1 2
1 x20 = 1 x 1 =1
0 x21
= 0 x 2 = 0
1 x22 = 1 x 4 = 4
(101)2 = (5)10
ii) (1 0 0 1 1)2
1x20 = 1x1 = 1
1x21 = 1x2 = 2
0x22 = 0x4 = 0
0x23 = 0x8 = 0
1x 24 = 1x16 = 16
(1011)2 = (19)10
iii) (0. 1 0 1)2
1x2−1 = 1x0.5 = 0.5
0x2−2 = 0x0.25 = 0
1x2−3 = 1x0.125 = 0.125
(0.101)2 = (0.625)10
Example 1.1
Convert (1101011.1011)2 to its equivalent decimal number.
Solution:
For integer part,
Dr. I. Manimehan, Department of Physics, MRGAC Page 3
(1 1 0 1 0 1 1)2
1 x 20 = 1x1 = 1
1 x 21 = 1x2 = 1
0 x 22 = 0x4 = 0
1x 23 = 1x8 = 8
0x 24 = 0x16 = 0
1x25 = 1x32 = 32
1x26 = 1x64 = 64
(1101011)2 = 107 10
For fraction part,
(.1 0 1 1)2
1x2−4 = 1x0.0625 = 0.0625
1x2−3 = 1x0.125 = 0.125
0x2−2 = 0x0.25 = 0
1x2−1 = 1x0.5 = 0.5
(.1 0 1 1)2 = (6875)10
(1101011.1011)2 = (107.6875)10
Dr. I. Manimehan, Department of Physics, MRGAC Page 4
1.4 DECIMAL TO BINARY CONVERSION
A decimal like 19 can be converted into binary by repeatedly dividing the number by 2
and collecting the remainders (double dabble method)
2 19
9 - 1 (LSB)
4 - 1
2 - 0
1 - 0
0 - 1 (MSB)
(19)10 = (10011)2
Example 1.2
Convert (107.6875)10 to its equivalent binary number.
Solution:
For integer part, divide by 2 repeatedly and collect the remainders.
2 107
53 - 1 (LSB)
26 - 1
13 - 0
6 - 1
3 - 0
1 - 1
0 - 1 (MSB)
(107)10 = (110 1011)2
Dr. I. Manimehan, Department of Physics, MRGAC Page 5
For the fractional part, multiply by 2 repeatedly and collect the carries.
0.6875x2 = 1.3750; carry 1 (MSB)
0.3750x2 = 0.7500; carry 0
0.7500x2 = 1.5000; carry 1
0.5000x2 = 1.0000; carry 1 (LSB)
Therefore, (107.6875)10 = (110 1011.1011)2
1.5 HEXADECIMAL NUMBER SYSTEM
The hexadecimal number system as a base 16. The basic digits are 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E, F. The base of the hexadecimal number system is 16 and the base of the
binary number system is 2. Since 24 = 16, it follows that any hex digit can be represented by a
group of four bit binary sequence.
The table (1.1) gives the decimal, hexadecimal and the four bit binary equivalence for the
decimal numbers 0 to 15.
Decimal
Hexadecimal
Binary
23 + 22 + 21 + 20
8 + 4 + 2 +1
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Dr. I. Manimehan, Department of Physics, MRGAC Page 6
1.6 HEXADECIMAL TO DECIMAL COVERSION
The hex to decimal conversion is similar to binary to decimal conversion, only the
weights are different. In this case, the weights used are 160, 161, 162 etc., for the integer part
and 16−1, 16−2, 16−3 etc., for the fractional part. In hexadecimal number system we have a
hexadecimal point.
Example 1.3
Convert the following hexadecimal numbers to decimal.
(a) (E9)H (b) (3FC.8)H (C) (FFFF)H
Solution:
(a) (E 9)H
9x160 = 9x1 = 9
14x161 = 14x16 = 224
(E9)H = (233)10
(b) (3FC.8)H
8x16−1 = 8x0.0625 = 0.5
12x 160 = 12x1 = 12
15x161 = 15x16 =240
3x 162= 3x 256 = 768
(3FC.8)H = (1020.5)10
(C) (F FF F)H
15x160 =15x1 = 15
15x161 = 15x16 = 240
15x 162 = 1 x256 = 3840
15x 163 = 15x4096 = 61440
(FFFF)H = (65535)10
Dr. I. Manimehan, Department of Physics, MRGAC Page 7
1.7 DECIMAL TO HEXADECIMAL CONVERSION
To convert a decimal number to hex, we have to divide the decimal number by 16
repeatedly and collect the remainders from top to bottom (for the integer part). The remainders
also must be taken in hex.
Example 1.4
Convert the following decimal numbers to hex equivalents
(a) 1020 (b) 98.625
Solution:
(a) 16 1020
63 - 12 C (LSB)
3 - 15 F
0 - 3 3 (MSB)
(1020)10 = (3FC) H
(b) The hex number 980625 is separated as the integer part 98 and fractional part .625. The
integer 98 is converted into hex by repeated division by 16.
16 98
6 - 2
0 - 6
(98)10 = (62)H
The fraction 0.625 is converted into hex by multiplying 0.625 by 16 and collecting the carry.
0.625 x 16 = 10.000
The carry obtained is 10 which must be taken in hex as ‘A’.
Therefore, (98.625)10 = (62.A) H
Dr. I. Manimehan, Department of Physics, MRGAC Page 8
1.8 HEXADECIMAL TO BINARY CONVERSION
To convert a decimal number to binary we have adopted a procedure of repeatedly
dividing the given decimal number by 2. Since the base of hexadecimal number system is 16
which is equal to 24, to convert a hexadecimal number to binary, all we have to do is replace
each hex digit with its equivalent 4-bit binary.
Table 1.1 gives the hex, decimal and the corresponding binary combination. Using the
table, we can write the binary equivalent of any hexadecimal number.
Example 1.5
Convert the following hexadecimal numbers to binary.
(a) (25)H (b) (3A.7)H (C) (CD.E8)H
Solution:
(a) (25)H = (0010 0101)2
(b) (3A.7)H = (0011 1010)2
(c) (CD.E8)H = (1100 1101.1110 1000)2
1.9 BINARY TO HEXADECIMAL CONVERSION
To convert a binary number to hex, we have to arrange the bits into group of 4 bits
starting from LSB (Least Significant Bit). If the final group has less than 4 bits, just include
zeros to make it a group of 4 bits. For example, 100101 2 into hex, arrange the bits as
10 0101 2. Now include two zeros for the first group at the front. The binary combination
now becomes 0010 0101 2. In last step replace each 4 bit binary group by its equivalent hex
digit. i.e, 0010=2 and 0101=5.
Therefore, 100101 2 = 0010 0101 2 = 25 H
The digit, whether it is an integer part or fractional part must be represented by a group of 4-bits.
For integer part, 4-bit groups are formed starting from the hexadecimal point and moving
towards left. For the fractional part, 4-bit groups are formed starting from the hexadecimal point
and moving towards right.
Example 1.6
Convert the following binary numbers to hexadecimal numbers.