Binary Octal and Hexadecimal Numbers
Binary Octal and Hexadecimal Numbers
Higher Engineering Mathematics. 978-1-138-67357-1, © 2017 John Bird. Published by Taylor & Francis. All rights reserved.
Binary, octal and hexadecimal numbers 91
Blaise Pascal∗ invented the first adding machine in of enemy targets. The advantages of digital comput-
Section A
1642. Twenty years later, an Englishman, Sir Samuel ers include speed, accuracy, and man-power savings.
Morland∗ , developed a more compact device that could Often computers are able to take over routine jobs and
multiply, add, and subtract. About 1672, Gottfried Wil- release personnel for more important work that can-
helm von Leibniz∗ perfected a machine that could not be handled by a computer. People and computers
perform all the basic operations (add, subtract, multi- do not normally speak the same language. Methods of
ply, divide), as well as extract the square root. Modern translating information into forms that are understand-
electronic digital computers still use von Leibniz’s able and usable to both are necessary. Humans generally
principles. speak in words and numbers expressed in the decimal
Computers are now employed wherever repeated number system, while computers only understand coded
calculations or the processing of huge amounts of data electronic pulses that represent digital information.
are needed. The greatest applications are found in the All data in modern computers is stored as series of
military, scientific, and commercial fields. They have bits, a bit being a binary digit, and can have one of
applications that range from mail sorting, and engi- two values, the numbers 0 and 1. The most basic form
neering design, to the identification and destruction of representing computer data is to represent a piece of
data as a string of 1s and 0s, one for each bit. This is
called a binary or base-2 number.
Because binary notation requires so many bits to rep-
resent relatively small numbers, two further compact
notations are often used, called octal and hexadeci-
mal. Computer programmers who design sequences of
number codes instructing a computer what to do would
have a very difficult task if they were forced to work
with nothing but long strings of 1s and 0s, the ‘native
language’ of any digital circuit.
Octal notation represents data as base-8 numbers with
each digit in an octal number representing three bits.
Similarly, hexadecimal notation uses base-16 numbers,
representing four bits with each digit. Octal numbers
use only the digits 0–7, while hexadecimal numbers
use all ten base-10 digits (0–9) and the letters A–F
(representing the numbers 10–15).
This chapter explains how to convert between the
decimal, binary, octal and hexadecimal systems.
Practice Exercise 39 Conversion of binary (most significant bit) .1 0 1 (least significant bit)
to decimal numbers (Answers on page 859)
For fractions, the most significant bit of the result is the
In Problems 1 to 5, convert the binary numbers top bit obtained from the integer part of multiplication
given to decimal numbers. by 2. The least significant bit of the result is the bottom
bit obtained from the integer part of multiplication by 2.
1. (a) 110 (b) 1011 (c) 1110 (d) 1001
Thus 0.625 10 = 0.1012
2. (a) 10101 (b) 11001 (c) 101101 (d) 110011
Binary, octal and hexadecimal numbers 93
Section A
0.3125 3 2 5 0.625
From above, repeatedly dividing by 2 and noting the 0.625 3 2 5 1.25
remainder gives: 0.25 3 2 5 0.5
0.5 325 1.0
2 47 Remainder
.0 1 0 1
2 23 1
2 11 1 Thus 58.3125 10 = 111010.0101 2
2 5 1
Now try the following Practice Exercise
2 2 1
2 1 0
Practice Exercise 40 Conversion of
0 1
decimal to binary numbers (Answers on
1 0 1 1 1 1 page 860)
Thus 4710 = 101111 2 In Problems 1 to 5, convert the decimal numbers
given to binary numbers.
1. (a) 5 (b) 15 (c) 19 (d) 29
Problem 5. Convert 0.40625 10 to a binary
number. 2. (a) 31 (b) 42 (c) 57 (d) 63
3. (a) 47 (b) 60 (c) 73 (d) 84
From above, repeatedly multiplying by 2 gives:
4. (a) 0.25 (b) 0.21875 (c) 0.28125
0.40625 3 2 5 0. 8125 (d) 0.59375
Table 10.1
Problem 13. Convert 5613.90625 10 to a binary
Section A
Octal digit Natural number, via octal.
binary number
The integer part is repeatedly divided by 8, noting the
0 000
remainder, giving:
1 001
8 5613 Remainder
2 010 8 701 5
3 011 8 87 5
8 10 7
4 100 8 1 2
5 101 0 1
6 110 1 2 7 5 5
Problem 11. Convert 3714 10 to a binary number, 127558 = 001 010 111 101 101 2
via octal. i.e. 561310 = 1 010 111 101 101 2
Dividing repeatedly by 8, and noting the remainder The fractional part is repeatedly multiplied by 8, and
gives: noting the integer part, giving:
8 3714 Remainder
8 464 2 0.90625 3 8 5 7.25
0.25 385 2.00
8 58 0
8 7 2 .7 2
0 7
This octal fraction is converted to a binary number,
7 2 0 2 (see Table 10.1).
From Table 10.1, 7202 8 = 111 010 000 010 2 0.728 = 0.111 010 2
i.e. 3714 10 = 111 010 000 010 2 i.e. 0.90625 10 = 0.111 01 2
In Problems 1 to 3, convert the decimal numbers Table 10.2 compares decimal, binary, octal and hexa-
given to binary numbers, via octal. decimal numbers and shows, for example, that
2310 = 101112 = 278 = 1716
1. (a) 343 (b) 572 (c) 1265
2. (a) 0.46875 (b) 0.6875 (c) 0.71875 Problem 15. Convert the following hexadecimal
numbers into their decimal equivalents:
3. (a) 247.09375 (b) 514.4375 (c) 1716.78125 (a) 7A16 (b) 3F16
4. Convert the binary numbers given to decimal
numbers via octal. (a) 7A16 = 7 × 161 + A × 160 = 7 × 16 + 10 × 1
(a) 111.011 1 (b) 101 001.01
(c) 1 110 011 011 010.001 1 = 112 + 10 = 122
Thus 7A16 = 12210
(b) 3F16 = 3 × 161 + F × 160 = 3 × 16 + 15 × 1
10.4 Hexadecimal numbers
= 48 + 15 = 63
The hexadecimal system is particularly important in
computer programming, since four bits (each consist- Thus 3F16 = 6310
ing of a one or zero) can be succinctly expressed using
a single hexadecimal digit. Two hexadecimal digits rep- Problem 16. Convert the following hexadecimal
resent numbers from 0 to 255, a common range used, numbers into their decimal equivalents:
for example, to specify colours. Thus, in the HTML (a) C916 (b) BD16
language of the web, colours are specified using three
pairs of hexadecimal digits RRGGBB, where RR is the (a) C916 = C × 161 + 9 × 160 = 12 × 16 + 9 × 1
amount of red, GG the amount of green, and BB the
amount of blue. = 192 + 9 = 201
A hexadecimal numbering system has a radix of
16 and uses the following 16 distinct digits: Thus C916 = 20110
Section A
Decimal Binary Octal Hexadecimal
This is achieved by repeatedly dividing by 16 and noting
0 0000 0 0 the remainder at each stage, as shown below for 26 10
1 0001 1 1
16 26 Remainder
2 0010 2 2 16 1 10 ; A16
3 0011 3 3 0 1 ; 116
(a) 16 162 Remainder to each group gives as above, from Table 10.2.
Section A
16 10 2 5 216
Thus, 11010110 2 = D616
0 10 5 A16
A 2 (b) Grouping bits in fours from the right gives:
0111
0110 and assigning hexadecimal symbols
Hence 16210 = A216 6 7
to each group gives as above, from Table 10.2.
(b) 16 239 Remainder Thus, 1100111 2 = 6716
16 14 15 5 F16
0 14 5 E16 Problem 21. Convert the following binary
E F numbers into their hexadecimal equivalents:
(a) 11001111 2 (b) 110011110 2
Hence 23910 = EF16
(a) Grouping bits in fours from the right gives:
Now try the following Practice Exercise 1100
1111
and assigning hexadecimal symbols
C F
to each group gives as above, from Table 10.2.
Practice Exercise 43 Hexadecimal
numbers (Answers on page 860) Thus, 11001111 2 = CF16
(b) Grouping bits in fours from the right gives:
In Problems 1 to 4, convert the given hexadecimal 1001
0001 1110
and assigning hexadecimal
numbers into their decimal equivalents. 1 9 E
symbols to each group gives as above, from
1. E716 2. 2C16
Table 10.2.
3. 9816 4. 2F116
Thus, 110011110 2 = 19E16
In Problems 5 to 8, convert the given decimal
numbers into their hexadecimal equivalents.
(d) Converting from hexadecimal to binary
5. 5410 6. 20010
The above procedure is reversed; thus, for example,
7. 9110 8. 23810
6CF316 = 0110 1100 1111 0011
from Table 10.2
(c) Converting from binary to hexadecimal i.e. 6CF316 = 110110011110011 2
The binary bits are arranged in groups of four, start-
ing from right to left, and a hexadecimal symbol is Problem 22. Convert the following hexadecimal
assigned to each group. For example, the binary num- numbers into their binary equivalents:
ber 1110011110101001 is initially grouped in fours as: (a) 3F16 (b) A616
1110
0111
1010
1001
and a hexadecimal symbol
E 7 A 9 (a) Spacing out hexadecimal digits gives:
assigned to each group as above, from Table 10.2. 3 F
and converting each into binary
Hence 1110011110101001 2 = E7A916 0011 1111
gives as above, from Table 10.2.
Thus, 3F16 = 111111 2
Problem 20. Convert the following binary
numbers into their hexadecimal equivalents: (b) Spacing out hexadecimal digits gives:
A 6
(a) 11010110 2 (b) 1100111 2 and converting each into binary
1010 0110
gives as above, from Table 10.2.
(a) Grouping bits in fours from the right gives: Thus, A616 = 10100110 2
1101
0110
and assigning hexadecimal symbols
D 6
Binary, octal and hexadecimal numbers 99
Section A
3. 10001011 2
numbers into their binary equivalents:
(a) 7B16 (b) 17D16 4. 10100101 2
In Problems 5 to 8, convert the given hexadecimal
(a) Spacing out hexadecimal digits gives: numbers into their binary equivalents.
7 B
and converting each into binary 5. 3716
0111 1011
gives as above, from Table 10.2. 6. ED16
Thus, 7B16 = 1111011 2 7. 9F16
1. 11010111 2
2. 11101010 2
For fully worked solutions to each of the problems in Practice Exercises 39 to 44 in this chapter,
go to the website:
www.routledge.com/cw/bird