Short Notes: Data Representation & Number System | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE) PDF Download

Download, print and study this document offline
Please wait while the PDF view is loading
 Page 1


                                                               
 
Data Representation and Number system 
Numeric systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
Radix number systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
A base of a number system or radix defines the range of values that a digit may have.   
In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".  
In the octal system or base 8, there can be eight choices for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7".  
In the decimal system or base 10, there are ten different values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".  
In the hexadecimal system, we allow 16 values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".  
Where “A” stands for 10, “B” for 11 and so on. 
Conversion among radices 
- Convert from Decimal to Any Base 
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it 
to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide 
the given number by its base 10.  
     1234/10 = 123 + 4/10 
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and 
see what drops out.  
     123/10 = 12 + 3/10 
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, 
you do the following:  
                    
Page 2


                                                               
 
Data Representation and Number system 
Numeric systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
Radix number systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
A base of a number system or radix defines the range of values that a digit may have.   
In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".  
In the octal system or base 8, there can be eight choices for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7".  
In the decimal system or base 10, there are ten different values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".  
In the hexadecimal system, we allow 16 values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".  
Where “A” stands for 10, “B” for 11 and so on. 
Conversion among radices 
- Convert from Decimal to Any Base 
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it 
to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide 
the given number by its base 10.  
     1234/10 = 123 + 4/10 
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and 
see what drops out.  
     123/10 = 12 + 3/10 
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, 
you do the following:  
                    
                                                               
 
Quotient  Remainder 
     ----------------------------- 
     1234/10 =   123        4 --------+ 
      123/10 =    12        3 ------+ | 
       12/10 =     1        2 ----+ | | 
        1/10 =     0        1 --+ | | |(Stop when the quotient is 0)                                                                             
                                | | | | 
                                1 2 3 4   (Base 10) 
 
Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note that the desired base is 
2, so we repeatedly divide the given decimal number by 2.  
               Quotient  Remainder 
     ----------------------------- 
     1341/2  =   670        1 ----------------------+ 
      670/2  =   335        0 --------------------+ | 
      335/2  =   167        1 ------------------+ | | 
      167/2  =    83        1 ----------------+ | | | 
       83/2  =    41        1 --------------+ | | | | 
       41/2  =    20        1 ------------+ | | | | | 
       20/2  =    10        0 ----------+ | | | | | | 
       10/2  =     5        0 --------+ | | | | | | | 
        5/2  =     2        1 ------+ | | | | | | | | 
        2/2  =     1        0 ----+ | | | | | | | | | 
        1/2  =     0        1 --+ | | | | | | | | | |(Stop when the 
                                | | | | | | | | | | | quotient is 0) 
                                1 0 1 0 0 1 1 1 1 0 1  (BIN; Base 2) 
 
Let's express the same decimal number 1341 in octal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/8  =   167        5 --------+ 
      167/8  =    20        7 ------+ | 
       20/8  =     2        4 ----+ | | 
        2/8  =     0        2 --+ | | |  (Stop when the quotient is 0) 
                                | | | | 
                                2 4 7 5  (OCT; Base 8) 
 
Let's express the same decimal number 1341 in hexadecimal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/16 =    83       13 ------+ 
       83/16 =     5        3 ----+ | 
        5/16 =     0        5 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                5 3 D  (HEX; Base 16) 
 
In conclusion, the easiest way to convert fixed point numbers to any base is to convert each part separately. We begin by 
separating the number into its integer and fractional part. The integer part is converted using the remainder method, by 
using a successive division of the number by the base until a zero is obtained. At each division, the reminder is kept and 
then the new number in the base r is obtained by reading the remainder from the lat remainder upwards.   
The conversion of the fractional part can be obtained by successively multiplying the fraction with the base. If we iterate 
this process on the remaining fraction, then we will obtain successive significant digit. This methods form the basis of 
the multiplication methods of converting fractions between bases  
Example. Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal equivalent of the 
decimal number 3315.3?  
Page 3


                                                               
 
Data Representation and Number system 
Numeric systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
Radix number systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
A base of a number system or radix defines the range of values that a digit may have.   
In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".  
In the octal system or base 8, there can be eight choices for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7".  
In the decimal system or base 10, there are ten different values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".  
In the hexadecimal system, we allow 16 values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".  
Where “A” stands for 10, “B” for 11 and so on. 
Conversion among radices 
- Convert from Decimal to Any Base 
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it 
to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide 
the given number by its base 10.  
     1234/10 = 123 + 4/10 
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and 
see what drops out.  
     123/10 = 12 + 3/10 
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, 
you do the following:  
                    
                                                               
 
Quotient  Remainder 
     ----------------------------- 
     1234/10 =   123        4 --------+ 
      123/10 =    12        3 ------+ | 
       12/10 =     1        2 ----+ | | 
        1/10 =     0        1 --+ | | |(Stop when the quotient is 0)                                                                             
                                | | | | 
                                1 2 3 4   (Base 10) 
 
Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note that the desired base is 
2, so we repeatedly divide the given decimal number by 2.  
               Quotient  Remainder 
     ----------------------------- 
     1341/2  =   670        1 ----------------------+ 
      670/2  =   335        0 --------------------+ | 
      335/2  =   167        1 ------------------+ | | 
      167/2  =    83        1 ----------------+ | | | 
       83/2  =    41        1 --------------+ | | | | 
       41/2  =    20        1 ------------+ | | | | | 
       20/2  =    10        0 ----------+ | | | | | | 
       10/2  =     5        0 --------+ | | | | | | | 
        5/2  =     2        1 ------+ | | | | | | | | 
        2/2  =     1        0 ----+ | | | | | | | | | 
        1/2  =     0        1 --+ | | | | | | | | | |(Stop when the 
                                | | | | | | | | | | | quotient is 0) 
                                1 0 1 0 0 1 1 1 1 0 1  (BIN; Base 2) 
 
Let's express the same decimal number 1341 in octal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/8  =   167        5 --------+ 
      167/8  =    20        7 ------+ | 
       20/8  =     2        4 ----+ | | 
        2/8  =     0        2 --+ | | |  (Stop when the quotient is 0) 
                                | | | | 
                                2 4 7 5  (OCT; Base 8) 
 
Let's express the same decimal number 1341 in hexadecimal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/16 =    83       13 ------+ 
       83/16 =     5        3 ----+ | 
        5/16 =     0        5 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                5 3 D  (HEX; Base 16) 
 
In conclusion, the easiest way to convert fixed point numbers to any base is to convert each part separately. We begin by 
separating the number into its integer and fractional part. The integer part is converted using the remainder method, by 
using a successive division of the number by the base until a zero is obtained. At each division, the reminder is kept and 
then the new number in the base r is obtained by reading the remainder from the lat remainder upwards.   
The conversion of the fractional part can be obtained by successively multiplying the fraction with the base. If we iterate 
this process on the remaining fraction, then we will obtain successive significant digit. This methods form the basis of 
the multiplication methods of converting fractions between bases  
Example. Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal equivalent of the 
decimal number 3315.3?  
                                                               
 
Solution:  
               Quotient  Remainder 
     ----------------------------- 
     3315/16 =   207        3 ------+ 
      207/16 =    12       15 ----+ | 
       12/16 =     0       12 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                C F 3  (HEX; Base 16) 
 
 
                                        (HEX; Base 16) 
                Product  Integer Part   0.4 C C C ... 
     --------------------------------     | | | | 
     0.3*16   =   4.8        4        ----+ | | | | | 
     0.8*16   =  12.8       12        ------+ | | | | 
     0.8*16   =  12.8       12        --------+ | | | 
     0.8*16   =  12.8       12        ----------+ | | 
              :                       ---------------------+ 
              : 
   Thus, 3315.3 (DEC) --> CF3.4CCC... (HEX) 
- Convert From Any Base to Decimal 
Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits); 
and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, 
and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:  
     Original Number:      1     2     3    4 
                           |     |     |    | 
     How Many Tokens:      1     2     3    4 
     Digit/Token Value: 1000   100    10    1 
     Value:             1000 + 200  + 30  + 4  = 1234 
or simply,  1*1000 + 2*100 + 3*10 + 4*1 = 1234 
Thus, each digit has a value: 10^
0
=1 for the least significant digit, increasing to 10^
1
=10, 10^
2
=100, 10^
3
=1000, and so 
forth.  
Likewise, the least significant digit in a hexadecimal number has a value of 16^
0
=1 for the least significant digit, 
increasing to 16^
1
=16 for the next digit, 16^
2
=256 for the next, 16^
3
=4096 for the next, and so forth. Thus, 1234 means 
that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 sixteen's in the 
next box, 2 256's in the next, and 1 4096's in the left-most box (most significant digit). The total is:  
     1*4096 + 2*256 + 3*16 + 4*1 = 4660 
In summary, the conversion from any base to base 10 can be obtained from the formulae 
?
-
- =
=
1
10
n
m i
i
i
b d x
 Where b is the base, d
i
 the digit at position i, m the number of digit after the decimal point, n the number 
of digits of the integer part and X
10
 is the obtained number in decimal. This form the basic of the polynomial method of 
converting numbers from any base to decimal 
Example. Convert 234.14 expressed in an octal notation to decimal. 
2*8
2 
+ 3*8
1 
+ 4*8
0
+1*8
-1 
+ 4*8
-2 
         = 2*64 +3*8 +4*1 +1/8 +4/64 =156.1875
 
Page 4


                                                               
 
Data Representation and Number system 
Numeric systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
Radix number systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
A base of a number system or radix defines the range of values that a digit may have.   
In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".  
In the octal system or base 8, there can be eight choices for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7".  
In the decimal system or base 10, there are ten different values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".  
In the hexadecimal system, we allow 16 values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".  
Where “A” stands for 10, “B” for 11 and so on. 
Conversion among radices 
- Convert from Decimal to Any Base 
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it 
to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide 
the given number by its base 10.  
     1234/10 = 123 + 4/10 
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and 
see what drops out.  
     123/10 = 12 + 3/10 
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, 
you do the following:  
                    
                                                               
 
Quotient  Remainder 
     ----------------------------- 
     1234/10 =   123        4 --------+ 
      123/10 =    12        3 ------+ | 
       12/10 =     1        2 ----+ | | 
        1/10 =     0        1 --+ | | |(Stop when the quotient is 0)                                                                             
                                | | | | 
                                1 2 3 4   (Base 10) 
 
Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note that the desired base is 
2, so we repeatedly divide the given decimal number by 2.  
               Quotient  Remainder 
     ----------------------------- 
     1341/2  =   670        1 ----------------------+ 
      670/2  =   335        0 --------------------+ | 
      335/2  =   167        1 ------------------+ | | 
      167/2  =    83        1 ----------------+ | | | 
       83/2  =    41        1 --------------+ | | | | 
       41/2  =    20        1 ------------+ | | | | | 
       20/2  =    10        0 ----------+ | | | | | | 
       10/2  =     5        0 --------+ | | | | | | | 
        5/2  =     2        1 ------+ | | | | | | | | 
        2/2  =     1        0 ----+ | | | | | | | | | 
        1/2  =     0        1 --+ | | | | | | | | | |(Stop when the 
                                | | | | | | | | | | | quotient is 0) 
                                1 0 1 0 0 1 1 1 1 0 1  (BIN; Base 2) 
 
Let's express the same decimal number 1341 in octal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/8  =   167        5 --------+ 
      167/8  =    20        7 ------+ | 
       20/8  =     2        4 ----+ | | 
        2/8  =     0        2 --+ | | |  (Stop when the quotient is 0) 
                                | | | | 
                                2 4 7 5  (OCT; Base 8) 
 
Let's express the same decimal number 1341 in hexadecimal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/16 =    83       13 ------+ 
       83/16 =     5        3 ----+ | 
        5/16 =     0        5 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                5 3 D  (HEX; Base 16) 
 
In conclusion, the easiest way to convert fixed point numbers to any base is to convert each part separately. We begin by 
separating the number into its integer and fractional part. The integer part is converted using the remainder method, by 
using a successive division of the number by the base until a zero is obtained. At each division, the reminder is kept and 
then the new number in the base r is obtained by reading the remainder from the lat remainder upwards.   
The conversion of the fractional part can be obtained by successively multiplying the fraction with the base. If we iterate 
this process on the remaining fraction, then we will obtain successive significant digit. This methods form the basis of 
the multiplication methods of converting fractions between bases  
Example. Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal equivalent of the 
decimal number 3315.3?  
                                                               
 
Solution:  
               Quotient  Remainder 
     ----------------------------- 
     3315/16 =   207        3 ------+ 
      207/16 =    12       15 ----+ | 
       12/16 =     0       12 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                C F 3  (HEX; Base 16) 
 
 
                                        (HEX; Base 16) 
                Product  Integer Part   0.4 C C C ... 
     --------------------------------     | | | | 
     0.3*16   =   4.8        4        ----+ | | | | | 
     0.8*16   =  12.8       12        ------+ | | | | 
     0.8*16   =  12.8       12        --------+ | | | 
     0.8*16   =  12.8       12        ----------+ | | 
              :                       ---------------------+ 
              : 
   Thus, 3315.3 (DEC) --> CF3.4CCC... (HEX) 
- Convert From Any Base to Decimal 
Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits); 
and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, 
and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:  
     Original Number:      1     2     3    4 
                           |     |     |    | 
     How Many Tokens:      1     2     3    4 
     Digit/Token Value: 1000   100    10    1 
     Value:             1000 + 200  + 30  + 4  = 1234 
or simply,  1*1000 + 2*100 + 3*10 + 4*1 = 1234 
Thus, each digit has a value: 10^
0
=1 for the least significant digit, increasing to 10^
1
=10, 10^
2
=100, 10^
3
=1000, and so 
forth.  
Likewise, the least significant digit in a hexadecimal number has a value of 16^
0
=1 for the least significant digit, 
increasing to 16^
1
=16 for the next digit, 16^
2
=256 for the next, 16^
3
=4096 for the next, and so forth. Thus, 1234 means 
that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 sixteen's in the 
next box, 2 256's in the next, and 1 4096's in the left-most box (most significant digit). The total is:  
     1*4096 + 2*256 + 3*16 + 4*1 = 4660 
In summary, the conversion from any base to base 10 can be obtained from the formulae 
?
-
- =
=
1
10
n
m i
i
i
b d x
 Where b is the base, d
i
 the digit at position i, m the number of digit after the decimal point, n the number 
of digits of the integer part and X
10
 is the obtained number in decimal. This form the basic of the polynomial method of 
converting numbers from any base to decimal 
Example. Convert 234.14 expressed in an octal notation to decimal. 
2*8
2 
+ 3*8
1 
+ 4*8
0
+1*8
-1 
+ 4*8
-2 
         = 2*64 +3*8 +4*1 +1/8 +4/64 =156.1875
 
                                                               
 
Example. Convert the hexadecimal number 4B3 to decimal notation. What about the decimal equivalent of the 
hexadecimal number 4B3.3?  
Solution:  
     Original Number:     4    B    3  .  3 
                          |    |    |     | 
     How Many Tokens:     4   11    3     3 
     Digit/Token Value: 256   16    1     0.0625 
     Value:            1024 +176  + 3   + 0.1875  = 1203.1875 
 
Example. Convert 234.14 expressed in an octal notation to decimal.  
Solution:  
     Original Number:     2    3    4  .  1       4 
                          |    |    |     |       | 
     How Many Tokens:     2    3    4     1       4 
     Digit/Token Value:  64    8    1     0.125   0.015625 
     Value:             128 + 24  + 4   + 0.125 + 0.0625    = 156.1875 
- Relationship between Binary - Octal  and Binary-hexadecimal 
As demonstrated by the table bellow, there is a direct correspondence between the binary system and the octal system, 
with three binary digits corresponding to one octal digit. Likewise, four binary digits translate directly into one 
hexadecimal digit.  
     BIN    OCT   HEX   DEC 
     ---------------------- 
     0000   00     0     0 
     0001   01     1     1 
     0010   02     2     2 
     0011   03     3     3 
     0100   04     4     4 
     0101   05     5     5 
     0110   06     6     6 
     0111   07     7     7 
     ---------------------- 
     1000   10     8     8 
     1001   11     9     9 
     1010   12     A    10 
     1011   13     B    11 
     1100   14     C    12 
     1101   15     D    13 
     1110   16     E    14 
     1111   17     F    15 
With such relationship, In order to convert a binary number to octal,  we partition the base 2 number into groups of three 
starting from the radix point, and pad the outermost groups with 0’s as needed to form triples. Then, we convert each 
triple to the octal equivalent.  
For conversion from base 2 to base 16, we use groups of four. 
 Consider converting 10110
2
 to base 8: 
10110
2
 = 010
2
  110
2
 = 2
8
  6
8
 = 26
8 
Notice that the leftmost two bits are padded with a 0 on the left in order to create a full triplet. 
Page 5


                                                               
 
Data Representation and Number system 
Numeric systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
Radix number systems 
The numeric system we use daily is the decimal system, but this system is not convenient for machines since the 
information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing 
the positional calculation which will allow us to express a number in any base where we need it. 
A base of a number system or radix defines the range of values that a digit may have.   
In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".  
In the octal system or base 8, there can be eight choices for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7".  
In the decimal system or base 10, there are ten different values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".  
In the hexadecimal system, we allow 16 values for each digit of a number:  
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".  
Where “A” stands for 10, “B” for 11 and so on. 
Conversion among radices 
- Convert from Decimal to Any Base 
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it 
to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide 
the given number by its base 10.  
     1234/10 = 123 + 4/10 
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and 
see what drops out.  
     123/10 = 12 + 3/10 
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, 
you do the following:  
                    
                                                               
 
Quotient  Remainder 
     ----------------------------- 
     1234/10 =   123        4 --------+ 
      123/10 =    12        3 ------+ | 
       12/10 =     1        2 ----+ | | 
        1/10 =     0        1 --+ | | |(Stop when the quotient is 0)                                                                             
                                | | | | 
                                1 2 3 4   (Base 10) 
 
Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note that the desired base is 
2, so we repeatedly divide the given decimal number by 2.  
               Quotient  Remainder 
     ----------------------------- 
     1341/2  =   670        1 ----------------------+ 
      670/2  =   335        0 --------------------+ | 
      335/2  =   167        1 ------------------+ | | 
      167/2  =    83        1 ----------------+ | | | 
       83/2  =    41        1 --------------+ | | | | 
       41/2  =    20        1 ------------+ | | | | | 
       20/2  =    10        0 ----------+ | | | | | | 
       10/2  =     5        0 --------+ | | | | | | | 
        5/2  =     2        1 ------+ | | | | | | | | 
        2/2  =     1        0 ----+ | | | | | | | | | 
        1/2  =     0        1 --+ | | | | | | | | | |(Stop when the 
                                | | | | | | | | | | | quotient is 0) 
                                1 0 1 0 0 1 1 1 1 0 1  (BIN; Base 2) 
 
Let's express the same decimal number 1341 in octal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/8  =   167        5 --------+ 
      167/8  =    20        7 ------+ | 
       20/8  =     2        4 ----+ | | 
        2/8  =     0        2 --+ | | |  (Stop when the quotient is 0) 
                                | | | | 
                                2 4 7 5  (OCT; Base 8) 
 
Let's express the same decimal number 1341 in hexadecimal notation.  
               Quotient  Remainder 
     ----------------------------- 
     1341/16 =    83       13 ------+ 
       83/16 =     5        3 ----+ | 
        5/16 =     0        5 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                5 3 D  (HEX; Base 16) 
 
In conclusion, the easiest way to convert fixed point numbers to any base is to convert each part separately. We begin by 
separating the number into its integer and fractional part. The integer part is converted using the remainder method, by 
using a successive division of the number by the base until a zero is obtained. At each division, the reminder is kept and 
then the new number in the base r is obtained by reading the remainder from the lat remainder upwards.   
The conversion of the fractional part can be obtained by successively multiplying the fraction with the base. If we iterate 
this process on the remaining fraction, then we will obtain successive significant digit. This methods form the basis of 
the multiplication methods of converting fractions between bases  
Example. Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal equivalent of the 
decimal number 3315.3?  
                                                               
 
Solution:  
               Quotient  Remainder 
     ----------------------------- 
     3315/16 =   207        3 ------+ 
      207/16 =    12       15 ----+ | 
       12/16 =     0       12 --+ | |  (Stop when the quotient is 0) 
                                | | | 
                                C F 3  (HEX; Base 16) 
 
 
                                        (HEX; Base 16) 
                Product  Integer Part   0.4 C C C ... 
     --------------------------------     | | | | 
     0.3*16   =   4.8        4        ----+ | | | | | 
     0.8*16   =  12.8       12        ------+ | | | | 
     0.8*16   =  12.8       12        --------+ | | | 
     0.8*16   =  12.8       12        ----------+ | | 
              :                       ---------------------+ 
              : 
   Thus, 3315.3 (DEC) --> CF3.4CCC... (HEX) 
- Convert From Any Base to Decimal 
Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits); 
and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, 
and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:  
     Original Number:      1     2     3    4 
                           |     |     |    | 
     How Many Tokens:      1     2     3    4 
     Digit/Token Value: 1000   100    10    1 
     Value:             1000 + 200  + 30  + 4  = 1234 
or simply,  1*1000 + 2*100 + 3*10 + 4*1 = 1234 
Thus, each digit has a value: 10^
0
=1 for the least significant digit, increasing to 10^
1
=10, 10^
2
=100, 10^
3
=1000, and so 
forth.  
Likewise, the least significant digit in a hexadecimal number has a value of 16^
0
=1 for the least significant digit, 
increasing to 16^
1
=16 for the next digit, 16^
2
=256 for the next, 16^
3
=4096 for the next, and so forth. Thus, 1234 means 
that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 sixteen's in the 
next box, 2 256's in the next, and 1 4096's in the left-most box (most significant digit). The total is:  
     1*4096 + 2*256 + 3*16 + 4*1 = 4660 
In summary, the conversion from any base to base 10 can be obtained from the formulae 
?
-
- =
=
1
10
n
m i
i
i
b d x
 Where b is the base, d
i
 the digit at position i, m the number of digit after the decimal point, n the number 
of digits of the integer part and X
10
 is the obtained number in decimal. This form the basic of the polynomial method of 
converting numbers from any base to decimal 
Example. Convert 234.14 expressed in an octal notation to decimal. 
2*8
2 
+ 3*8
1 
+ 4*8
0
+1*8
-1 
+ 4*8
-2 
         = 2*64 +3*8 +4*1 +1/8 +4/64 =156.1875
 
                                                               
 
Example. Convert the hexadecimal number 4B3 to decimal notation. What about the decimal equivalent of the 
hexadecimal number 4B3.3?  
Solution:  
     Original Number:     4    B    3  .  3 
                          |    |    |     | 
     How Many Tokens:     4   11    3     3 
     Digit/Token Value: 256   16    1     0.0625 
     Value:            1024 +176  + 3   + 0.1875  = 1203.1875 
 
Example. Convert 234.14 expressed in an octal notation to decimal.  
Solution:  
     Original Number:     2    3    4  .  1       4 
                          |    |    |     |       | 
     How Many Tokens:     2    3    4     1       4 
     Digit/Token Value:  64    8    1     0.125   0.015625 
     Value:             128 + 24  + 4   + 0.125 + 0.0625    = 156.1875 
- Relationship between Binary - Octal  and Binary-hexadecimal 
As demonstrated by the table bellow, there is a direct correspondence between the binary system and the octal system, 
with three binary digits corresponding to one octal digit. Likewise, four binary digits translate directly into one 
hexadecimal digit.  
     BIN    OCT   HEX   DEC 
     ---------------------- 
     0000   00     0     0 
     0001   01     1     1 
     0010   02     2     2 
     0011   03     3     3 
     0100   04     4     4 
     0101   05     5     5 
     0110   06     6     6 
     0111   07     7     7 
     ---------------------- 
     1000   10     8     8 
     1001   11     9     9 
     1010   12     A    10 
     1011   13     B    11 
     1100   14     C    12 
     1101   15     D    13 
     1110   16     E    14 
     1111   17     F    15 
With such relationship, In order to convert a binary number to octal,  we partition the base 2 number into groups of three 
starting from the radix point, and pad the outermost groups with 0’s as needed to form triples. Then, we convert each 
triple to the octal equivalent.  
For conversion from base 2 to base 16, we use groups of four. 
 Consider converting 10110
2
 to base 8: 
10110
2
 = 010
2
  110
2
 = 2
8
  6
8
 = 26
8 
Notice that the leftmost two bits are padded with a 0 on the left in order to create a full triplet. 
                                                               
 
Now consider converting 10110110
2
 to base 16: 
10110110
2
 = 1011
2
  0110
2
 = B
16
  6
16
 = B6
16 
(Note that ‘B’ is a base 16 digit corresponding to 11
10
. B is not a variable.) 
The conversion methods can be used to convert a number from any base to any other base, but it may not be very 
intuitive to convert something like 513.03
 
to base 7. As an aid in performing an unnatural conversion, we can convert to 
the more familiar base 10 form as an intermediate step, and then continue the conversion from base 10 to the target base. 
As a general rule, we use the polynomial method when converting into base 10, and we use the remainder and 
multiplication methods when converting out of base 10. 
Numeric complements 
The radix complement of an n digit number y in radix b is, by definition, b
n
 - y. Adding this to x results in the value x + 
b
n
 - y or x - y + b
n
. Assuming y = x, the result will always be greater than b
n
 and dropping the initial '1' is the same as 
subtracting b
n
, making the result x - y + b
n
 - b
n
 or just x - y, the desired result. 
The radix complement is most easily obtained by adding 1 to the diminished radix complement, which is (b
n
 - 1) - y . 
Since (b
n
 - 1) is the digit b - 1 repeated n times (because b
n
 - 1 = b
n
 - 1
n
 = (b - 1)(b
n - 1
 + b
n - 2
 + ... + b + 1) = (b - 1)b
n 
- 1
 + ... + (b - 1), see also binomial numbers), the diminished radix complement of a number is found by complementing 
each digit with respect to b - 1 (that is, subtracting each digit in y from b - 1). Adding 1 to obtain the radix complement 
can be done separately, but is most often combined with the addition of x and the complement of y. 
In the decimal numbering system, the radix complement is called the ten's complement and the diminished radix 
complement the nines' complement.  
In binary, the radix complement is called the two's complement and the diminished radix complement the ones' 
complement. The naming of complements in other bases is similar.  
- Decimal example 
To subtract a decimal number y from another number x using the method of complements, the ten's complement of y 
(nines' complement plus 1) is added to x. Typically, the nines' complement of y is first obtained by determining the 
complement of each digit. The complement of a decimal digit in the nines' complement system is the number that must 
be added to it to produce 9. The complement of 3 is 6, the complement of 7 is 2, and so on. Given a subtraction 
problem: 
   873  (x) 
- 218  (y) 
The nines' complement of y (218) is 781. In this case, because y is three digits long, this is the same as subtracting y 
from 999. (The number of 9's is equal to the number of digits of y.) 
Next, the sum of x, the nines' complement of y, and 1 is taken: 
  873  (x) 
+ 781  (complement of y) 
+   1  (to get the ten's complement of y) 
===== 
 1655  
The first "1" digit is then dropped, giving 655, the correct answer. 
If the subtrahend has fewer digits than the minuend, leading zeros must be added which will become leading nines when 
the nines' complement is taken. For example: 
Read More
90 docs

Top Courses for Computer Science Engineering (CSE)

90 docs
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Sample Paper

,

Exam

,

ppt

,

Short Notes: Data Representation & Number System | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

,

mock tests for examination

,

study material

,

Short Notes: Data Representation & Number System | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

,

Extra Questions

,

Important questions

,

pdf

,

Previous Year Questions with Solutions

,

practice quizzes

,

Summary

,

MCQs

,

shortcuts and tricks

,

Free

,

past year papers

,

Viva Questions

,

Semester Notes

,

Short Notes: Data Representation & Number System | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

,

video lectures

,

Objective type Questions

;