Bases and Number Representations: 2.1. Real Numbers and Decimal System
Bases and Number Representations: 2.1. Real Numbers and Decimal System
Chapter 2
Bases and number representations
The way a number is represented depends on the number system used. In our daily life, we use
the decimal system. Thus, when the price tag shows Dhs. 1110, this automatically is understood
as a representation for “one-thousand one-hundred and ten” in the decimal system.
The decimal system uses ten basic representations of numbers (in latin convention):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
This basic representation can only represent up to “nine”. For any number larger than “nine”, the
system relies on the position. To represent “ten”, another positional digit is added to allow us to
write “10”. To represent, “eleven” we fill up the right-most digit with 1 to have “11”, etc. Using
two positional digits, we can only represent numbers upto “ninty-nine”, which is 99. Thus, we
need another positional digit to represent larger numbers. For “one-hundred”, we add a third digit
to write “100”; etc.
Example 1.
2175.368 can be expanded as follows:
In Example 1, notice that the fraction part is expanded into the sum of negative powers of 10.
The numbers 2, 1, 7, 5, 3, 6, and 8 are the digits and 10 is the base for this expansion. Because
of this, the decimal system is also called as the base-10 system or base of 10 system.
The binary system is a number system using two basic representations and expressible in an
expansion of powers of 2. The two representations in the binary system are 0 and 1.
Since 0 and 1 are also representations in the decimal system, a subscript “2” is used to indicate
if a number belongs to the binary system. The binary system is also called as the base-2 system.
Example 2.
a. 11102 is a binary number. It is expandable as a sum of powers of 2 as follows:
11102 = 1 × 23 + 1 × 22 + 1 × 21 + 0 × 20 .
1 × 22 + 0 × 21 + 1 × 20 + ⏟
101.012 = ⏟ 0 × 2−1 + 1 × 2−2
whole number part fraction part
The numbers 1, 1, 1, and 0 in Example 2(a) are the digits and 2 is the base for this expansion.
Remark: Without the subscript, 1110 is always a decimal number. To emphasize the difference,
however, we shall always use the subscript “10” to indicate a decimal number.
Expansion of a binary number as a sum of powers of 2 provides a way to convert the number to
a decimal number.
Chapter 2. Bases and number representations
Example 3.
Convert 11102 to a decimal number.
Answer.
Using the expansion in Example 2,
11102 = 1 × 23 + 1 × 22 + 1 × 21 + 0 × 20
=1 ×8 +1×4 +1×2 +0×1
= 8 + 4 + 2 + 0
= 14
Conversion of a binary number with fraction part is done in a similar way, involving negative
powers of 2.
Example 4.
Convert 0.1012 to a decimal number.
Answer.
Expansion in terms of powers of 2,
Example 5.
Convert 11011.0012 to a decimal number.
Answer.
Expansion in terms of powers of 2,
Example 6.
1
21 ÷ 5 = 4
5
For this division, the quotient (whole number part) is 4, and the remainder is 1.
• 21 div 5 = 4
• 21 mod 5 = 1
Converting a decimal number to a binary number is equivalent to expanding the decimal number
into a sum of powers of 2 (not 10 as described in Section 2.1). Consider 1410 . Normally the
expansion takes the form: 1410 = 1 × 101 + 4 × 100 . But now we want to have an expansion
in powers of 2.
14 = 14 + 0 = 14 + 0 × 20 = 7 × 2 + 0 × 20 = 𝟕 × 21 + 𝟎 × 20 .
We now have an expansion in terms of the two lowest powers of 2: 21 and 20 . Notice that
14 div 2 = 7 and 14 mod 2 = 0. Thus, this expansion involves division of 14 by 2. The digit of
the 20 term is 0, which is one of the binary representations. However, 7 is not. So, the above
expansion does not represent a binary number yet.
7 = 6 + 1 = 6 + 1 × 20 = 3 × 2 + 1 × 20 = 𝟑 × 21 + 𝟏 × 20 .
Notice again that 7 div 2 = 3 and 7 mod 2 = 1. Thus, expansion of 7 above involves division
of 7 by 2. Substitution of the above expansion to the expansion of 14 leads to
14 = (𝟑 × 21 + 𝟏 × 20 ) × 21 + 𝟎 × 20
= 3 × 21 × 21 + 1 × 20 × 21 + 0 × 20
= 𝟑 × 22 + 𝟏 × 21 + 𝟎 × 20 .
Chapter 2. Bases and number representations
We have an additional power of 2 in the expansion, but this does not represent a binary number,
because the digit 3 is not a binary number. We now expand 3 as follows:
3 = 2 + 1 = 𝟏 × 21 + 𝟏 × 20 ,
14 = (𝟏 × 21 + 1 × 20 ) × 22 + 𝟏 × 21 + 𝟎 × 20 = 𝟏 × 23 + 𝟏 × 22 + 𝟏 × 21 + 𝟎 × 20 .
Now all digits in the expansion are either 0 or 1. Thus, the expansion on the right-hand side
represents a binary number, which is 11102 . So, 1410 = 11102 .
From the above illustration, conversion of a decimal number involves continues division of 𝑛 ←
𝑛 div 2. The binary digit is then given by 𝑛 mod 2 in each division. This process is summarized
in Algorithm 1.
Note that the first loop gives an output which is the first binary digit, the second loop gives an
output which is the second digit, etc.
Chapter 2. Bases and number representations
Example 7.
Convert 1410 to a binary number.
Answer.
We follow steps in Algorithm 1. Here, 𝑛 = 14. Since 𝑛 ≠ 0, we do the first repeat-until loop.
In Step 2.1., we have 𝑛 mod 2 = 14 mod 2 = 0. Thus, our first output is 0. In Step 2.2.,
𝑛 div 2 = 14 div 2 = 7. This value is assigned as the new 𝑛; thus, now 𝑛 = 7. The first binary
digit is the first output 0. So, up to this stage we have
02
Because 𝑛 = 7 ≠ 0, we do the second loop. In Step 2.1., 𝑛 mod 2 = 7 mod 2 = 1. The second
output is 1. In Step 2.2., 𝑛 div 2 = 7 div 2 = 3. We assign 3 as the new 𝑛. Thus, 𝑛 = 3. The
output 1 is the second binary digit. So, at this stage we have
102
With 𝑛 = 3 ≠ 0, we continue with the third loop. Step 2.1. gives the third output 𝑛 mod 2 =
3 mod 2 = 1. Step 2.2 updates 𝑛 to 𝑛 = 3 div 2 = 1 The solution at this stage is
1102
𝑛 = 1 ≠ 0, so we repeat the loop. At this stage, with 𝑛 = 1, Step 2.1. produces 𝑛 mod 2 = 1
as the fourth output, and Step 2.2. gives 𝑛 div 2 = 1 div 2 = 0 as the new 𝑛. The solution at
this stage is
11102
Now 𝑛 = 0; So, the repeat-until loop is terminated. So,11102 is the final solution.
This solution can also be constructed by collecting the outputs and writing them from the last
to the first.
The workflow described in Example 7 is more visible from a tracing table, as shown below.
Collecting the outputs from below to the top gives the conversion result: 11102 .
Note that since 𝑛 ← 𝑛 𝑑𝑖𝑣 2, we actually do not need the 𝑛 div 2 column. Also, because
output = 𝑛 mod 2, we also do not need the output column. The above tracing table can therefore
be simplified further, into something like this.
𝑛 𝑛 mod 2
Divide 𝑛 by 2 to get the new 14
𝑛 ← 𝑛 div 2 7 0
3 1
1 1
0 1
Reading the last column from below to the top gives the conversion result: 11102 .
Example 8.
Convert 2710 to a binary number.
Answer.
The process is summarized in the simplified table below.
𝑛 𝑛 mod 2
Divide 𝑛 by 2 to get the new 121
𝑛 ← 𝑛 div 2 60 1
30 0
15 0
7 1
3 1
1 1
0 1
Reading the last column from the bottom to the top gives the conversion result: 11110012 .
Conversion of the fraction part of a decimal number can be done in a similar way as for the while
number part. In this case, however, construction of an expansion involves multiplications by 2.
We skip the detail and just present the algorithm.
Chapter 2. Bases and number representations
In the above algorithm, the symbol ⌊𝑚⌋ means the whole number part of 𝑚 and frac(𝑚) the
fraction part of 𝑚. For instance,
⌊2.125⌋ = 2 and frac(2.125) = 0.125;
⌊0.025⌋ = 0 and frac(0.025) = 0.025.
In Algorithm 2, the input ``digits’’ is used to set the number of digits used in the fraction part. In
some cases, the algorithm will reach 𝑛 = 0 and terminate after a limited number of loops. But it
is possible that the algorithm requires a large number of loops in order to reach 𝑛 = 0 or even
never reaches it at all.
For instance, 0.7510 = 0.112 . In this case, after 2 loops, the algorithm produces 𝑛 = 0 and
terminates.
For 0.810 , however, the algorithm still does not produce 𝑛 = 0 after 20 loops. After 20 steps, it
gives 0.110011001100110011012 = 0.80000019073486328125 … ≠ 0.810. To reach this
solution is already a tedious work if it is done by hand. If we are interested in the first 8 digits,
for instance, we can set 𝑑𝑖𝑔𝑖𝑡𝑠 = 8 in the algorithm, and the loop will be terminated after 8 loops.
The conversion result is 0.110011002 . Keep in mind that we do not round the result; instead we
just chop it after the 8-th fraction digit. Converting this back to decimal gives 0.110011002 =
0.79687510 ≠ 0.810.
Chapter 2. Bases and number representations
Example 9.
Convert 0.12510 to a binary number, up to the 6-th fraction digit.
Answer.
Here, 𝑛 = 0.125 and 𝑑𝑖𝑔𝑖𝑡𝑠 = 6. Following the algorithm, we start with Step 2, with 𝑖 = 0.
Since 𝑛 ≠ 0 and 𝑖 ≠ 𝑑𝑖𝑔𝑖𝑡𝑠 = 6, we initiate the first return-until loop.
In Step 3.1, 𝑖 = 0 + 1 = 1. This corresponds to the first fraction digit. In Step 3.2., 𝑚 = 2𝑛 =
2 × 0.125 = 0.25. With this, from Step 3.3., we get our first output: ⌊𝑚⌋ = ⌊0.25⌋ = 0. In
Step 3.4., frac(𝑚) = frac(0.25) = 0.25. This value is assigned as the new 𝑛; thus, 𝑛 = 0.25.
Since 𝑛 ≠ 0 and 𝑖 = 1 ≠ 𝑑𝑖𝑔𝑖𝑡𝑠, we will do a second loop.
In Step 3.2, 𝑖 = 1 + 1 = 2; so, we are now computing the second fraction digit. In Step 3.2.,
𝑚 = 2𝑛 = 2 × 0.25 = 0.50. With this, from Step 3.3., we get the second output: ⌊𝑚⌋ =
⌊0.50⌋ = 0. In Step 3.4., frac(𝑚) = frac(0.5) = 0.5. This value is assigned as the new 𝑛;
thus, 𝑛 = 0.5. Since 𝑛 ≠ 0 and 𝑖 = 2 ≠ 𝑑𝑖𝑔𝑖𝑡𝑠, we will do a third loop.
Reading from the first output to the last leads to the conversion result: 0.0012 . In this case,
we do not need 6 digits to represent 0.12510 in the binary system.
Reading the output column top-down, we get the conversion result: 0.0012 .
The tracing table can be simplified by showing only the 𝑚, ⌊𝑚⌋, and 𝑛, as in the below table.
Reading the ⌊𝑚⌋ column top-down gives the conversion result: 0.0012 .
𝑖 𝑚 ⌊𝑚⌋ 𝑛
0 0.125 Multiply 𝑛 by 2 to get 𝑚
1 0.25 0 0.25
2 0.50 0 0.50
3 1.0 1 0
Example 10.
Convert 0.27510 to a binary number, up to the 8-th fractional digit.
Answer.
The process is summarized in the following table.
𝑖 𝑚 ⌊𝑚⌋ 𝑛
0 0.275 Multiply 𝑛 by 2 to get 𝑚
1 0.55 0 0.55
2 1.10 1 0.10
3 0.20 0 0.20
4 0.40 0 0.40
5 0.80 0 0.80
6 1.60 1 0.60
7 1.20 1 0.20
8 0.40 0 0.80
Reading the ⌊𝑚⌋ column top-down, the conversion results up to the 8-th fractional digit is
0.010001102 .
Exercise 2.3. Convert the following decimal numbers to a binary number, up to the 6th
fraction digit.
a. 0.4210 b. 0.2510 c. 0.1210
To convert a decimal number with a whole number and fraction part to a binary number, we just
do conversion for each part and then combine the result.
Chapter 2. Bases and number representations
Example 11.
Convert 14.27510 to a binary number, with the fraction part up to the 8th fraction digit.
Answer.
From Example 7, 1410 = 11102 . From Example 11, 0.27510 = 0.010001102 (using 8
fraction digits). Combining the two results,
14.27510 = 1110.010001102 .
Exercise 2.4. Convert the following decimal numbers to a binary number, up to the 6th
fraction digit.
b. 75.610 b. 180.0110 c. 63.8510
In addition to the binary system, there are some others number systems. We shall discuss
• Octal number system
• Hexadecimal number system
To distinguish with a decimal number, an octal number is indicated by the subscript “8”. Thus,
5678 is an octal number, and not a decimal number.
An octal number can be expanded into a sum of powers of 8. The system is therefore called also
as the base-8 or base of 8 system. The fraction part of an octal number is expanded into a sum
of negative powers of 8.
Example 12.
• 5678 = 5 × 82 + 6 × 81 + 7 × 80
• 1205.238 = 1 × 83 + 2 × 82 + 0 × 81 + 5 × 80 + 2 × 8−1 + 3 × 8−2
5, 6 and 7 in the expansion of 5678 are the digits; in 1205.238 , the digits are 1, 2, 0, 5, 2, 3.
There are 2 fraction digits: 2 and 3.
Like for the binary system, this expansion provides a way to convert an octal number to a decimal
number.
Chapter 2. Bases and number representations
Example 13.
Convert 5678 and 1205.238 to a decimal number.
Answer.
Using expansion in Example 12,
• 5678 = 5 × 82 + 6 × 81 + 7 × 80 = 5 × 64 + 6 × 8 + 7 × 1 = 37510
The hexadecimal system uses 16 basic representations, hence called base-16 or base of 16:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 𝐴, 𝐵, 𝐶, 𝐷, 𝐸, 𝐹.
A hexadecimal number is indicated by the subscript “16”. Thus, 56716 is a hexadecimal number,
and not an octal or decimal number. A hexadecimal number can be expanded into a sum of
powers of 16. The fraction part of a hexadecimal number is expanded into a sum of negative
powers of 16. This expansion provides a way to convert an octal number to a decimal number.
A summary of conversions of the first sixteen numbers between binary, octal, decimal, and
hexadecimal is shown in Table 1.
Table 1. Conversion between binary, octal, decimal, and hexadecimals
Binary Octal Decimal Hexadecimal
02 08 010 016
12 18 110 116
102 28 210 216
112 38 310 316
1002 48 410 416
1012 58 510 516
1102 68 610 616
1112 78 710 716
10002 108 810 816
10012 118 910 916
10102 128 1010 𝐴16
10112 138 1110 𝐵16
11002 148 1210 𝐶16
11012 158 1310 𝐷16
11102 168 1410 𝐸16
11112 178 1510 𝐹16
Chapter 2. Bases and number representations
Example 13.
Convert the following hexadecimal numbers to a decimal number.
• 567.216
• 𝐴1𝐵. 𝐹916
Answer.
Using expansion in the powers of 16,
567.216 = 5 × 162 + 6 × 161 + 7 × 160 + 2 × 16−1
= 5 × 256 + 6 × 16 + 7 × 1 + 1 × 0.0625
= 1383.12510 .
Next,
𝐴1𝐵. 𝐹916 = 𝐴 × 162 + 1 × 161 + 𝐵 × 160 + 𝐹 × 16−1 + 9 × 16−2 .
From Table 1, we have 𝐴16 = 1010 , 𝐵16 = 1110 , and 𝐹16 = 1510 . Using these relations in the
expansion leads to
To convert a decimal whole number to an octal or hexadecimal whole number, we shall use the
following general algorithm, for any base 𝑏.
Note that for octal, 𝑏 = 8, and for hexadecimal, 𝑏 = 16. Notice that if 𝑏 = 2, Algorithm 3 is
identical with Algorithm 1.
Remember that
• the division of a whole number by 8 gives 0, 1, 2, 3, 4, 5, 6, or 7 as a remainder;
• the division of a whole number by 16 gives 0, 1, 2, 3, … 14, or 15 as a remainder.
To convert a decimal fraction to an octal or hexadecimal fraction, we shall use the following
general algorithm, for any base 𝑏.
Chapter 2. Bases and number representations
Example 14.
Convert 27910 to an octal number.
Answer.
Conversion of a decimal whole number to an octal is done using Algorithm 3, with 𝑏 = 8.
Summary of the process is given in the below table. To understand the table, recall that we
need to divide 279 by 𝑏 = 8 to get values in the second row of the table. This leads to two
parts:
To get the third row, you can again use a calculator and compute 34 ÷ 8, which gives 4.25.
Thus, 34 div 8 = 4. Multiplying the fraction part by 8, you get 0.25 × 8 = 2 = 34 mod 8.
Etc.
𝑛 𝑛 𝑚𝑜𝑑 8
Divide 𝑛 by 8 to compute the new 𝑛 279
34 7
4 2
0 4
Reading the 𝑚 mod 8 column bottom-up gives the conversion result: 4278 .
Chapter 2. Bases and number representations
Example 15.
Convert 70310 to a hexadecimal number.
Answer.
Converting to a hexadecimal number is done using Algorithm 3, with 𝑏 = 16. The summary
of the process is given in the table, below. To get the second row, we divide 703 by 𝑏 = 16.
Using calculator, 703 ÷ 16 = 43.9375. Thus, 703 div 16 = 43, the whole number part.
Multiplying the fraction part by 16 gives 0.9375 × 16 = 15, which is 703 mod 16. But
remember, 15 is not a basic representation in the hexadecimal system. From Table 1, 15 is
equal to 𝐹16 .
To get the third row, you can again use a calculator to compute 43 ÷ 16, which gives 2.6875.
Thus, 43 div 16 = 2. Multiplying the fraction part by 16, you get 0.6875 × 16 = 11 =
𝑛 mod 16. From Table 1, 11 = 𝐵16. Etc.
𝑛 𝑛 mod 16
Divide 𝑛 by 16 to compute the new 𝑛 703
43 15 (= F)
2 11 (= B)
0 2
Reading the 𝑛 mod 16 column bottom-up gives the conversion result: 2𝐵𝐹16 .
Chapter 2. Bases and number representations
Example 16.
Convert 0.27810 to an octal number and a hexadecimal number, up to the 6th fraction digit.
Answer.
To convert to an octal number, use Algorithm 4 with 𝑏 = 8. The result is summarized in the
following table, up to 𝑖 = 6 (the number of fraction digits needed).
𝑖 𝑚 ⌊𝑚⌋ 𝑛
0 0.278 Multiply 𝑛 by 8 to get 𝑚
1 2.224 2 0.224
2 1.792 1 0.792
3 6.336 6 0.336
4 2.688 2 0.688
5 5.504 5 0.504
6 4.032 4 0.032
Reading the ⌊𝑚⌋ column top-down gives the conversion result: 0.2162548 .
To convert to a hexadecimal number, use Algorithm 4 with 𝑏 = 16. The result is summarized
in the following table, up to 𝑖 = 6 (the number of fraction digits needed). Notice that at the 4th
loop, ⌊𝑚⌋ = 11 is converted to 𝐵16.
𝑖 𝑚 ⌊𝑚⌋ 𝑛
0 0.278 Multiply 𝑛 by 16 to get 𝑚
1 4.448 4 0.448
2 7.168 7 0.168
3 2.688 2 0.688
4 11.008 11 (= B) 0.008
5 0.128 0 0.128
6 2.048 2 0.048
Reading the ⌊𝑚⌋ column top-down gives the conversion result: 0.472𝐵0216 .
For a decimal number has a mixed whole number and fraction part, the conversion to an octal or
hexadecimal number is done separately. The conversion result from each part is then combined
to form the desired result.
Chapter 2. Bases and number representations
Example 17.
Convert 703.27810 to an octal number and a hexadecimal number, up to the 6th fraction digit.
Answer.
To convert 703.27810 , we shall convert 70310 and 0.27810 to an octal number separately.
For 0.27810 the conversion is done in Example 18, giving 0.2162548 . So, we just need to
convert the whole number part. The conversion process using Algorithm 3 is summarized in
the following table.
𝑛 𝑛 mod 8
Divide 𝑛 by 8 to compute the new 𝑛 703
87 7
10 7
1 2
0 1
Reading the 𝑛 mod 8 column bottom-up gives the conversion result: 12778 . Combining the
two results, we have 703.27810 = 1277.2162548 (up to 6 fraction digits).
Exercise 2.6. Convert the following decimal number to an octal and hexadecimal number
a. 32510 b. 94710 c. 115010
Exercise 2.7. Convert the following decimal number to an octal and hexadecimal number,
up to the 6th fraction digit
a. 0.810 b. 0.2510 c. 645.310 d. 197.1210 e. 1005.910
= 1 × 23 + 22 + 1 × 20
= 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
Now the right-hand side resembles an expansion of a binary number in powers of 2. The number
is given by the digits: 11012 . Thus, 158 = 11012 .
A similar approach can also be used to convert a hexadecimal number to a binary number,
because 16 = 24 .
For quick calculation, we shall not use the approach just described line-by-line. Instead, we shall
use a shortcut based on the above expansion. For the above example, notice that 5 = 4 + 1 =
1 × 22 + 0 × 21 + 1 × 20 = 1012 . Similarly, 1 = 1 × 20 = 0 × 22 + 0 × 21 + 1 × 21 =
0012 . Thus, if we replace 1 in 158 by 0012 and 5 by 1012 we will get 0011012 ; i.e.,
⏟
1 ⏟
5 = 001 1012
0012 1012
The two zeros on the left are called “leading zero” and can be dropped. The final answer is 158 =
11012 .
To convert an octal number to a binary number, what we have to do then is to replace each digit
in the octal number by a three-digit binary equal to it. Table 1 shows this conversion, but not all
in a three-digit form. Thus, we must pad with 0 to form a 3-digit binary. For example, 38 =
112 = 0112 , after padding one 0.
Example 18.
Convert 7428 to a binary number.
Answer.
From Table 1, and after padding to form a 3-digit binary,
78 = 1112 , 48 = 1102 , 28 = 102 = 0102
Thus,
⏟
7 ⏟
4 ⏟
2 = 111 110 0102 .
1112 1102 0102
Chapter 2. Bases and number representations
Example 19.
Convert 173.248 to a binary number.
Answer.
From Table 1, and after padding to form a 3-digit binary,
18 = 12 = 0012 , 78 = 1112 , 38 = 112 = 0112 , 28 = 0102 , 48 = 1002 .
Thus,
⏟
1 ⏟
7 ⏟
3 . ⏟
2 ⏟
4 = 001 111 011 . 010 1002
0012 1112 0112 0102 1002
The leading zeros can be dropped. The last two zeros in the fraction part, called the trailing
zeros, can also be dropped. The result of the conversion is 173.248 = 1111011.01012 .
Conversion from a hexadecimal number to a binary number can be done similarly, but by
replacing each digit in the hexadecimal number by the corresponding 4-digit binary.
Example 20.
Convert 2𝐴9.1𝐶16 to a binary number.
Answer.
From Table 1 and after padding to form a 4-digit binary,
216 = 102 = 00102 , 𝐴16 = 10102 , 916 = 10012 ,
116 = 12 = 00012 , 𝐶16 = 11002
Thus,
⏟
2 ⏟ 𝐴 ⏟ 9 . ⏟ 1 ⏟ 𝐶 = 0010 1010 1001 . 0001 11002
00102 10102 10012 00012 11002
Dropping the leading and trailing zeros, we get the result: 2𝐴9.1𝐶16 =
1010101001.0001112 .
Example 21.
Convert 1010101001.000112 to an octal number.
Answer.
We group the digits into 3, starting at the fractional point.
⏟
1 010
⏟ 101
⏟ 001
⏟ . 000
⏟ 11⏟
Notice that the left group in the whole number part has only 1 digit; in this case, we must pad
it with 2 leading zeros to from a 3-digit group. The right group in the fraction part has only 2
digits. We pad it with 1 trailing zero. After padding, the grouping looks like this:
001
⏟ 010
⏟ 101
⏟ 001
⏟ . 000
⏟ 110
⏟
Referring to Table 1, we can do conversion of each 3-digit to an octal number, to get
001
⏟ 010
⏟ 101
⏟ 001
⏟ . 000
⏟ 110
⏟ = 1251.068
18 28 58 18 08 68
Example 21.
Convert 1010101001.000112 to a hexadecimal number.
Answer.
We group the digits into 4, starting at the fractional point.
10
⏟ 1010
⏟ ⏟
1001 . 0001
⏟ ⏟
1
The left group only has 2 digits: so we pad it by two leading zeros. The right-most group has
only 1 digit; so, we pad it by three trailing zeros. The result after padding looks like this:
⏟
0010 ⏟
1010 ⏟
1001 . 0001
⏟ ⏟
1000
Converting each group to a hexadecimal number gives the result:
⏟
0010 ⏟
1010 ⏟
1001 . 0001
⏟ ⏟
1000 = 2𝐴9.1816 .
216 𝐴16 916 116 816
To convert to a hexadecimal number, we form a group of 4-digit binary starting from the
fractional point, to the left for the whole number part and to the right for the fraction part. Each
4-digit binary group is then converted to a hexadecimal number. A group with less than 4 digits
is padded with necessary zeros.
Chapter 2. Bases and number representations
Example 22.
Convert 7𝐴1.9𝐹16 to an octal number.
Answer.
Remember that 16 ≠ 8𝑘 , for any integer 𝑘. So, we cannot use the trick described above. What
we can do is to convert the hexadecimal number to a decimal number, and then convert the
resulting decimal number to an octal number. This seems to be a bit complicated. An easier
way is to convert the hexadecimal number to a binary number, and then convert it to an octal
number, as we shall show now.
= 11110100001.100111112 .
Next, we convert the binary number to an octal number:
11
⏟ 110
⏟ 100
⏟ 001
⏟ . 100
⏟ 111
⏟ 11
⏟ = 011
⏟ 110
⏟ 100
⏟ 001
⏟ . 100
⏟ 111
⏟ 110
⏟ = 3641.4768 .
38 68 48 18 48 78 68
Converting an octal number to a hexadecimal number is done in a similar way, by first converting
to a binary number.