Chapter 10
Binary, octal and
hexadecimal
10.1 Introduction
All data in modern computers is stored as series of bits,
a bit being a binary digit, and can have one of two values,
the numbers 0 and 1. The most basic form of representing computer data is to represent a piece of data as a
string of 1’s and 0’s, one for each bit. This is called a
binary or base-2 number.
Because binary notation requires so many bits to represent relatively small numbers, two further compact
notations are often used, called octal and hexadecimal. 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 1’s and 0’s, 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.
10.2 Binary numbers
The system of numbers in everyday use is the denary
or decimal system of numbers, using the digits 0 to 9.
It has ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9)
and is said to have a radix or base of 10.
The binary system of numbers has a radix of 2 and
uses only the digits 0 and 1.
(a) Conversion of binary to decimal
The decimal number 234.5 is equivalent to
2 × 10
2
+ 3 × 10
1
+ 4 × 10
0
+ 5 × 10
−1
i.e. is the sum of terms comprising: (a digit) multiplied
by (the base raised to some power).
In the binary system of numbers, the base is 2, so
1101.1 is equivalent to:
1 × 2
3
+ 1 × 2
2
+ 0 × 2
1
+ 1 × 2
0
+ 1 × 2
−1
Thus the decimal number equivalent to the binary
number 1101.1 is 8 + 4 +0 + 1 +
1
2 , that is 13.5 i.e.
1101.1 2 = 13.5 10 , the suffixes 2 and 10 denoting binary
and decimal systems of numbers respectively.
Problem 1. Convert 11011 2 to a decimal number.
From above: 11011 2 = 1 × 2
4
+ 1 × 2
3
+ 0 × 2
2
+ 1 × 2
1
+ 1 × 2
0
= 16 + 8 + 0 + 2 + 1
= 27 10
Problem 2. Convert 0.1011 2 to a decimal
fraction.
0.1011 2 = 1 ×2
−1
+ 0 × 2
−2
+ 1 × 2
−3
+ 1 × 2
−4
= 1 ×
1
2
+ 0 ×
1
2 2 + 1 ×
1
2 3 + 1 ×
1
2 4
Binary, octal and
hexadecimal
10.1 Introduction
All data in modern computers is stored as series of bits,
a bit being a binary digit, and can have one of two values,
the numbers 0 and 1. The most basic form of representing computer data is to represent a piece of data as a
string of 1’s and 0’s, one for each bit. This is called a
binary or base-2 number.
Because binary notation requires so many bits to represent relatively small numbers, two further compact
notations are often used, called octal and hexadecimal. 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 1’s and 0’s, 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.
10.2 Binary numbers
The system of numbers in everyday use is the denary
or decimal system of numbers, using the digits 0 to 9.
It has ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9)
and is said to have a radix or base of 10.
The binary system of numbers has a radix of 2 and
uses only the digits 0 and 1.
(a) Conversion of binary to decimal
The decimal number 234.5 is equivalent to
2 × 10
2
+ 3 × 10
1
+ 4 × 10
0
+ 5 × 10
−1
i.e. is the sum of terms comprising: (a digit) multiplied
by (the base raised to some power).
In the binary system of numbers, the base is 2, so
1101.1 is equivalent to:
1 × 2
3
+ 1 × 2
2
+ 0 × 2
1
+ 1 × 2
0
+ 1 × 2
−1
Thus the decimal number equivalent to the binary
number 1101.1 is 8 + 4 +0 + 1 +
1
2 , that is 13.5 i.e.
1101.1 2 = 13.5 10 , the suffixes 2 and 10 denoting binary
and decimal systems of numbers respectively.
Problem 1. Convert 11011 2 to a decimal number.
From above: 11011 2 = 1 × 2
4
+ 1 × 2
3
+ 0 × 2
2
+ 1 × 2
1
+ 1 × 2
0
= 16 + 8 + 0 + 2 + 1
= 27 10
Problem 2. Convert 0.1011 2 to a decimal
fraction.
0.1011 2 = 1 ×2
−1
+ 0 × 2
−2
+ 1 × 2
−3
+ 1 × 2
−4
= 1 ×
1
2
+ 0 ×
1
2 2 + 1 ×
1
2 3 + 1 ×
1
2 4
