14 - Binary Hexadecimal Number
14 - Binary Hexadecimal Number
All data in modern computers is stored as series of bits, (a) Conversion of binary to decimal
a bit being a binary digit, and can have one of two values, The decimal number 234.5 is equivalent to
the numbers 0 and 1. The most basic form of represent-
ing computer data is to represent a piece of data as a 2 × 102 + 3 × 101 + 4 × 100 + 5 × 10−1
string of 1’s and 0’s, one for each bit. This is called a
binary or base-2 number. i.e. is the sum of terms comprising: (a digit) multiplied
Because binary notation requires so many bits to rep- by (the base raised to some power).
resent relatively small numbers, two further compact In the binary system of numbers, the base is 2, so
notations are often used, called octal and hexadeci- 1101.1 is equivalent to:
mal. Computer programmers who design sequences of 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 + 1 × 2−1
number codes instructing a computer what to do would
have a very difficult task if they were forced to work Thus the decimal number equivalent to the binary
with nothing but long strings of 1’s and 0’s, the ‘native number 1101.1 is 8 + 4 +0 + 1 + 12 , that is 13.5 i.e.
language’ of any digital circuit. 1101.1 2 = 13.510 , the suffixes 2 and 10 denoting binary
Octal notation represents data as base-8 numbers with and decimal systems of numbers respectively.
each digit in an octal number representing three bits.
Similarly, hexadecimal notation uses base-16 numbers, Problem 1. Convert 110112 to a decimal number.
representing four bits with each digit. Octal numbers
use only the digits 0–7, while hexadecimal numbers From above: 110112 = 1 ×24 + 1 × 23 + 0 × 22
use all ten base-10 digits (0–9) and the letters A–F
(representing the numbers 10–15). + 1 × 21 + 1 × 20
This chapter explains how to convert between the = 16 + 8 + 0 + 2 + 1
decimal, binary, octal and hexadecimal systems.
= 2710
1 1 1 2 39 Remainder
= + +
2 8 16 2 19 1
= 0.5 + 0.125 + 0.0625 2 9 1
2 4 1
= 0.687510 2 2 0
2 1 0
0 1
Problem 3. Convert 101.0101 2 to a decimal
number. 1 0 0 1 1 1
(most significant bit) (least significant bit)
101.01012 = 1 × 22 + 0 × 21 + 1 ×20 + 0 × 2−1 The result is obtained by writing the top digit of the
remainder as the least significant bit, (a bit is a binary
+ 1 × 2−2 + 0 × 2−3 + 1 × 2−4 digit and the least significant bit is the one on the right).
= 4 + 0 + 1 + 0 + 0.25 + 0 + 0.0625 The bottom bit of the remainder is the most significant
bit, i.e. the bit on the left.
= 5.312510
Thus 3910 = 1001112
The fractional part of a decimal number can be converted
Now try the following exercise to a binary number by repeatedly multiplying by 2, as
shown below for the fraction 0.625
0.625 3 2 5 1. 250
Exercise 38 Further problems on
conversion of binary to decimal numbers
0.250 3 2 5 0. 500
In Problems 1 to 5, convert the binary numbers
given to decimal numbers. 0.500 3 2 5 1. 000
Problem 6. Convert 58.312510 to a binary 5. (a) 47.40625 (b) 30.8125 (c) 53.90625
number. (d) 61.65625
(a) 101111.011012
The integer part is repeatedly divided by 2, giving:
(b) 11110.11012
2 58 Remainder (c) 110101.11101
2
2 29 0
(d) 111101.101012
2 14 1
2 7 0
2 3 1 (c) Binary addition
2 1 1 Binary addition of two/three bits is achieved according
0 1 to the following rules:
1 1 1 0 1 0
sum carry sum carry
The fractional part is repeatedly multiplied by 2 giving: 0+0 =0 0 0+0 +0 = 0 0
0+1 =1 0 0+0+1 = 1 0
0.3125 3 2 5 0.625
0.625 3 2 5 1.25
1+0 =1 0 0+1+0 = 1 0
0.25 3 2 5 0.5 1+1 = 0 1 0+1+1 = 0 1
0.5 325 1.0 1+0+0 = 1 0
1+0+1 = 0 1
.0 1 0 1 1+1+0 = 0 1
Thus 58.312510 = 111010.01012 1+1+1 = 1 1
These rules are demonstrated in the following worked
Now try the following exercise problems.
Dividing repeatedly by 8, and noting the remainder 127558 = 001 010 111 101 1012
gives: i.e. 561310 = 1 010 111 101 1012
8 3714 Remainder
The fractional part is repeatedly multiplied by 8, and
8 464 2 noting the integer part, giving:
8 58 0
0.90625 3 8 5 7.25
8 7 2
0.25 385 2.00
0 7
.7 2
7 2 0 2
This octal fraction is converted to a binary number,
(see Table 10.1).
From Table 10.1, 72028 = 111 010 000 0102
i.e. 3714 10 = 111 010 000 0102
0.728 = 0.111 0102
Problem 12. Convert 0.59375 10 to a binary i.e. 0.9062510 = 0.111 012
number, via octal.
Thus, 5613.9062510 = 1 010 111 101 101.111 012
Multiplying repeatedly by 8, and noting the integer
values, gives:
Problem 14. Convert 11 110 011.100 012 to a
decimal number via octal.
0.59375 3 8 5 4.75
0.75 385 6.00
Grouping the binary number in three’s from the binary
.4 6 point gives: 011 110 011.100 0102
92 Higher Engineering Mathematics
Using Table 10.1 to convert this binary number to an pairs of hexadecimal digits RRGGBB, where RR is the
octal number gives 363.428 and 363.428 amount of red, GG the amount of green, and BB the
amount of blue.
= 3 × 82 + 6 × 81 + 3 × 80 + 4 × 8−1 + 2 × 8−2 A hexadecimal numbering system has a radix of
16 and uses the following 16 distinct digits:
= 192 + 48 + 3 + 0.5 + 0.03125
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
= 243.5312510
‘A’ corresponds to 10 in the decimal system, B to 11,
C to 12, and so on.
Now try the following exercise
(a) Converting from hexadecimal to decimal:
Exercise 41 Further problems on For example
conversion between decimal and binary
numbers via octal 1A16 = 1 × 161 + A × 160
3. (a) 247.09375 (b) 514.4375 (c) 1716.78125 and 1BF16 = 1 × 162 + B × 161 + F × 160
(a) 11110111.000112
= 1 × 162 + 11 × 161 + 15 × 160
(b) 1000000010.0111 2
(c) 11010110100.110012 = 256 + 176 + 15 = 44710
4. Convert the binary numbers given to decimal Table 10.2 compares decimal, binary, octal and hexa-
numbers via octal. decimal numbers and shows, for example, that
(a) 111.011 1 (b) 101 001.01 2310 = 101112 = 278 = 1716
(c) 1 110 011 011 010.001 1
(a) 7.437510 (b) 41.2510 Problem 15. Convert the following hexadecimal
(c) 7386.187510 numbers into their decimal equivalents:
(a) 7A16 (b) 3F16
Table 10.2
Problem 16. Convert the following hexadecimal
Decimal Binary Octal Hexadecimal numbers into their decimal equivalents:
0 0000 0 0 (a) C9 16 (b) BD16
1 0001 1 1
(a) C916 = C × 161 + 9 × 160 = 12 × 16 + 9 × 1
2 0010 2 2
= 192 + 9 = 201
3 0011 3 3
Thus C916 = 20110
4 0100 4 4
(b) BD16 = B × 161 + D × 160
5 0101 5 5
= 11 × 16 + 13 × 1 = 176 + 13 = 189
6 0110 6 6
Thus BD16 = 18910
7 0111 7 7
8 1000 10 8 Problem 17. Convert 1A4E16 into a decimal
number.
9 1001 11 9
10 1010 12 A 1A4E16 = 1 × 163 + A × 162 + 4 × 161 + E × 160
11 1011 13 B
= 1 × 163 + 10 × 162 + 4 × 161
12 1100 14 C + 14 × 160
13 1101 15 D
= 1 × 4096 + 10 × 256 + 4 × 16 + 14× 1
14 1110 16 E
= 4096 + 2560 + 64 + 14 = 6734
15 1111 17 F
Thus 1A4E16 = 673410
16 10000 20 10
17 10001 21 11
(b) Converting from decimal to hexadecimal
18 10010 22 12
This is achieved by repeatedly dividing by 16 and noting
19 10011 23 13 the remainder at each stage, as shown below for 26 10 .
20 10100 24 14
16 26 Remainder
21 10101 25 15 16 1 10 ; A16
22 10110 26 16 0 1 ; 116
27 11011 33 1B
16 447 Remainder
28 11100 34 1C 16 27 15 ; F16
29 11101 35 1D 16 1 11 ; B16
0 1 ; 116
30 11110 36 1E
1 B F
31 11111 37 1F
32 100000 40 20
Thus 44710 = 1BF16
94 Higher Engineering Mathematics
Problem 18. Convert the following decimal In Problems 5 to 8, convert the given decimal
numbers into their hexadecimal equivalents: numbers into their hexadecimal equivalents.
(a) 3710 (b) 10810
5. 5410 [3616] 6. 20010 [C816]
(a) 16 37 Remainder 7. 9110 [5B16] 8. 23810 [EE 16]
16 2 5 5 516
0 2 5 216
(c) Converting from binary to hexadecimal:
2 5
The binary bits are arranged in groups of four, start-
most significant bit least significant bit
ing from right to left, and a hexadecimal symbol is
assigned to each group. For example, the binary num-
Hence 3710 = 2516
ber 1110011110101001 is initially grouped in fours as:
1110 0111 1010 1001
(b) 16 108 Remainder and a hexadecimal symbol
16 6 12 5 C16 E 7 A 9
assigned to each group as above from Table 10.2.
0 6 5 616
Hence 11100111101010012 = E7A916
6 C
symbols to each group gives as above from (a) Spacing out hexadecimal digits gives:
Table 10.2. 7 B
and converting each into binary
0111 1011
Thus, 110011110 2 = 19E16 gives as above from Table 10.2.
Thus, 7B16 = 11110112
(d) Converting from hexadecimal to binary: (b) Spacing out hexadecimal digits gives:
1 7 D
The above procedure is reversed, thus, for example, and converting each into
0001 0111 1101
binary gives as above from Table 10.2.
6CF316 = 0110 1100 1111 0011
from Table 10.2 Thus, 17D16 = 101111101 2
This Revision Test covers the material contained in Chapters 8 to 10. The marks for each question are shown in
brackets at the end of each question.
1. Use Maclaurin’s series to determine a power series Use Newton’s method to determine the value of x,
for e2x cos 3x as far as the term in x 2 . (9) correct to 2 decimal places, for which the value of
y is zero. (10)
2. Show, using Maclaurin’s series, that the first four
terms of the power series for cosh 2x is given by:
7. Convert the following binary numbers to decimal
2 4 form:
cosh 2x = 1 + 2x + x 4 + x 6 .
2
(10)
3 45
(a) 1101 (b) 101101.0101 (5)
3. Expand the function x 2 ln(1 + sin x) using
Maclaurin’s series and hence evaluate: 8. Convert the following decimal number to binary
1 form:
2
x 2 ln(1 + sin x)dx correct to 2 significant (a) 27 (b) 44.1875 (9)
0
figures. (13)
4. Use the method of bisection to evaluate the root 9. Convert the following decimal numbers to binary,
of the equation: x 3 + 5x = 11 in the range x = 1 to via octal:
x = 2, correct to 3 significant figures. (11) (a) 479 (b) 185.2890625 (9)
5. Repeat question 4 using an algebraic method of
successive approximations. (16) 10. Convert
6. The solution to a differential equation associated (a) 5F16 into its decimal equivalent
with the path taken by a projectile for which the
(b) 13210 into its hexadecimal equivalent
resistance to motion is proportional to the velocity
is given by: (c) 1101010112 into its hexadecimal equivalent
x −x
y = 2.5(e − e ) + x − 25 (8)