Number Systems
Number Systems
All data in modern computers is stored as series of bits, a (a) Conversion of binary to decimal:
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 term 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
number codes instructing a computer what to do, would 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 + 1 × 2−1
have a very difficult task if they were forced to work
with nothing but long strings of 1s and 0s, the ‘native Thus the decimal number equivalent to the binary
language’ of any digital circuit. number 1101.1 is
Octal notation represents data as base-8 numbers
with each digit in an octal number representing three 1
8 + 4 + 0 + 1 + , that is 13.5
bits. Similarly, hexadecimal notation uses base-16 2
numbers, representing four bits with each digit. Octal
i.e. 1101.12 = 13.510 , the suffixes 2 and 10 denoting
numbers use only the digits 0–7, while hexadecimal
binary and decimal systems of number respectively.
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 Problem 1. Convert 110112 to a decimal number
decimal, binary, octal and hexadecimal systems.
2. (a) 10101 (b) 11001 (c) 101101 (d) 110011 0.500 3 2 5 1. 000
[(a) 2110 (b) 2510 (c) 4510 (d) 5110 ]
(most significant bit) .1 0 1 (least significant bit)
3. (a) 101010 (b) 111000 (c) 1000001
(d) 10111000 For fractions, the most significant bit of the result is the
[(a) 4210 (b) 5610 (c) 6510 (d) 18410] top bit obtained from the integer part of multiplication
by 2. The least significant bit of the result is the bot-
4. (a) 0.1101 (b) 0.11001 (c) 0.00111 tom bit obtained from the integer part of multiplication
(d) 0.01011 by 2.
(a) 0.812510 (b) 0.7812510
(c) 0.2187510 (d) 0.3437510 Thus 0.62510 = 0.1012
Binary, octal and hexadecimal 21
Section 1
Problem 4. Convert 4710 to a binary number
giving:
From above, repeatedly dividing by 2 and noting the
remainder gives: 0.3125 3 2 5 0.625
2 47 Remainder 0.625 3 2 5 1.25
0.25 3 2 5 0.5
2 23 1
0.5 325 1.0
2 11 1
.0 1 0 1
2 5 1
2 2 1
2 1 0 Thus 58.312510 = 111010.01012
0 1
0.625 325 1. 25
2. (a) 31 (b) 42 (c) 57 (d) 63
0.25 325 0. 5
(a) 111112 (b) 1010102
(c) 1110012 (d) 1111112
0.5 325 1. 0
The fractional part of a decimal number can be con- Dividing repeatedly by 8, and noting the remainder
Section 1
verted to an octal number by repeatedly multiplying by gives:
8, as shown below for the fraction 0.437510
8 3714 Remainder
0.4375 3 8 5 3. 5 8 464 2
8 58 0
0.5 385 4. 0 8 7 2
0 7
.3 4
7 2 0 2
For fractions, the most significant bit is the top integer
obtained by multiplication of the decimal fraction by 8,
From Table 3.1, 72028 = 111 010 000 0102
thus
i.e. 371410 = 111 010 000 0102
0.437510 = 0.348
The natural binary code for digits 0 to 7 is shown Problem 12. Convert 0.5937510 to a binary
in Table 3.1, and an octal number can be converted number, via octal
to a binary number by writing down the three bits
corresponding to the octal digit. Multiplying repeatedly by 8, and noting the integer
values, gives:
Thus 4378 = 100 011 1112
and 26.358 = 010 110.011 1012 0.59375 3 8 5 4.75
0.75 385 6.00
.4 6
Table 3.1
Octal digit Natural Thus 0.5937510 = 0.468
binary number
From Table 3.1, 0.468 = 0.100 1102
0 000
i.e. 0.5937510 = 0.100 112
1 001
Problem 13. Convert 5613.9062510 to a binary
2 010
number, via octal
3 011
The integer part is repeatedly divided by 8, noting the
4 100 remainder, giving:
Problem 11. Convert 371410 to a binary number, 127558 = 001 010 111 101 1012
via octal
i.e. 561310 = 1 010 111 101 1012
24 Engineering Mathematics
= 243.5312510 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
‘A’ corresponds to 10 in the denary system, B to 11, C
to 12, and so on.
Now try the following exercise
Table 3.2 compares decimal, binary, octal and hexadec- Table 3.2
Section 1
imal numbers and shows, for example, that
Decimal Binary Octal Hexadecimal
2310 = 101112 = 278 = 1716
0 0000 0 0
Section 1
Problem 21. Convert the following binary Problem 23. Convert the following hexadecimal
numbers into their hexadecimal equivalents: numbers into their binary equivalents: (a) 7B16
(a) 110011112 (b) 1100111102 (b) 17D16
(a) Grouping bits in fours from the (a) Spacing out hexadecimal
right gives: 1100 1111 digits gives: 7 B
and assigning hexadecimal and converting each into
symbols to each group gives: C F binary gives: 0111 1011
from Table 3.2 from Table 3.2
Thus, 110011112 = CF16 Thus, 7B16 = 11110112
(b) Grouping bits in fours from (b) Spacing out hexadecimal
the right gives: 0001 1001 1110 digits gives: 1 7 D
and assigning hexadecimal and converting each into
symbols to each group gives: 1 9 E binary gives: 0001 0111 1101
from Table 3.2 from Table 3.2
Thus, 1100111102 = 19E16 Thus, 17D16 = 1011111012
(d) Converting from hexadecimal to binary: Now try the following exercise
The above procedure is reversed, thus, for example,
Exercise 15 Further problems on
6CF316 = 0110 1100 1111 0011 hexadecimal numbers
from Table 3.2
i.e. 6CF316 = 1101100111100112 In Problems 1 to 4, convert the given binary
numbers into their hexadecimal equivalents.
Problem 22. Convert the following hexadecimal 1. 110101112 [D716]
numbers into their binary equivalents: (a) 3F16 2. 111010102 [EA16 ]
(b) A616
3. 100010112 [8B16]
(a) Spacing out hexadecimal digits gives: 3 F 4. 101001012 [A516]
and converting each into In Problems 5 to 8, convert the given hexadecimal
binary gives: 0011 1111 numbers into their binary equivalents.
from Table 3.2 5. 3716 [1101112]
Thus, 3F16 = 1111112 6. ED16 [111011012]
(b) Spacing out hexadecimal digits 7. 9F16 [100111112]
gives: A 6 8. A2116 [1010001000012]
and converting each into binary
gives: 1010 0110
from Table 3.2
Thus, A616 = 101001102