0% found this document useful (0 votes)
181 views10 pages

14 - Binary Hexadecimal Number

The document discusses binary, octal, and hexadecimal numbering systems used in computers. It explains that binary represents data as strings of 1s and 0s, with each bit representing a single digit. Octal and hexadecimal are more compact notations that use base-8 and base-16 numbers to represent binary digits in groups of 3 and 4 bits respectively. The document provides examples of converting decimal numbers to binary and vice versa by dividing or multiplying by powers of the radix (2 for binary, 8 for octal, 16 for hexadecimal).

Uploaded by

Qwert R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
181 views10 pages

14 - Binary Hexadecimal Number

The document discusses binary, octal, and hexadecimal numbering systems used in computers. It explains that binary represents data as strings of 1s and 0s, with each bit representing a single digit. Octal and hexadecimal are more compact notations that use base-8 and base-16 numbers to represent binary digits in groups of 3 and 4 bits respectively. The document provides examples of converting decimal numbers to binary and vice versa by dividing or multiplying by powers of the radix (2 for binary, 8 for octal, 16 for hexadecimal).

Uploaded by

Qwert R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 10

Binary, octal and


hexadecimal
The binary system of numbers has a radix of 2 and
10.1 Introduction uses only the digits 0 and 1.

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

10.2 Binary numbers Problem 2. Convert 0.10112 to a decimal


fraction.
The system of numbers in everyday use is the denary
or decimal system of numbers, using the digits 0 to 9. 0.1011 2 = 1 ×2−1 + 0 × 2−2 + 1 ×2−3 + 1 × 2−4
It has ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9) 1 1 1 1
= 1× +0× 2 +1× 3 +1× 4
and is said to have a radix or base of 10. 2 2 2 2
88 Higher Engineering Mathematics

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

1. (a) 110 (b) 1011 (c) 1110 (d) 1001


(most significant bit) .1 0 1 (least significant bit)
[(a) 610 (b) 1110 (c) 1410 (d) 910 ]
For fractions, the most significant bit of the result is the
2. (a) 10101 (b) 11001 (c) 101101 (d) 110011
top bit obtained from the integer part of multiplication
[(a) 2110 (b) 2510 (c) 4510 (d) 5110 ] by 2. The least significant bit of the result is the bottom
3. (a) 101010 (b) 111000 (c) 1000001 bit obtained from the integer part of multiplication by 2.
(d) 10111000
Thus 0.62510 = 0.1012
[(a) 4210 (b) 5610 (c) 6510 (d) 18410 ]
4. (a) 0.1101 (b) 0.11001 (c) 0.00111 Problem 4. Convert 4710 to a binary number.
(d) 0.01011
(a) 0.812510 (b) 0.7812510 From above, repeatedly dividing by 2 and noting the
(c) 0.2187510 (d) 0.3437510 remainder gives:
2 47 Remainder
5. (a) 11010.11 (b) 10111.011 (c) 110101.0111
(d) 11010101.10111 2 23 1

(a) 26.7510 (b) 23.37510 2 11 1

(c) 53.437510 (d) 213.7187510 2 5 1


2 2 1
2 1 0
(b) Conversion of decimal to binary 0 1
An integer decimal number can be converted to a cor-
1 0 1 1 1 1
responding binary number by repeatedly dividing by 2
and noting the remainder at each stage, as shown below Thus 4710 = 1011112
for 3910 .
Binary, octal and hexadecimal 89

Problem 5. Convert 0.4062510 to a binary 1. (a) 5 (b) 15 (c) 19 (d) 29


number.
(a) 1012 (b) 11112
From above, repeatedly multiplying by 2 gives: (c) 100112 (d) 111012

0.40625 3 2 5 0. 8125 2. (a) 31 (b) 42 (c) 57 (d) 63


(a) 111112 (b) 1010102
0.8125 3 2 5 1. 625
(c) 1110012 (d) 1111112
0.625 325 1. 25
3. (a) 47 (b) 60 (c) 73 (d) 84
(a) 1011112 (b) 1111002
0.25 325 0. 5
(c) 10010012 (d) 10101002
0.5 325 1. 0
4. (a) 0.25 (b) 0.21875 (c) 0.28125
(d) 0.59375
.0 1 1 0 1
(a) 0.012 (b) 0.001112
i.e. 0.4062510 = 0.011012 (c) 0.010012 (d) 0.100112

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.

Problem 7. Perform the binary addition:


Exercise 39 Further problems on 1001 + 10110
conversion of decimal to binary numbers
In Problems 1 to 5, convert the decimal numbers 1001
+10110
given to binary numbers. 11111
90 Higher Engineering Mathematics

Problem 8. Perform the binary addition: 10.3 Octal numbers


11111 + 10101
For decimal integers containing several digits, repeat-
11111 edly dividing by 2 can be a lengthy process. In this case,
+10101 it is usually easier to convert a decimal number to a
sum 110100
carry 11111 binary number via the octal system of numbers. This
system has a radix of 8, using the digits 0, 1, 2, 3, 4,
5, 6 and 7. The decimal number equivalent to the octal
Problem 9. Perform the binary addition:
number 43178 is:
1101001 + 1110101
1101001 4 × 83 + 3 × 82 + 1 × 81 + 7 × 80
+1110101
sum 11011110 i.e. 4 × 512 + 3 × 64 + 1 × 8 + 7 × 1 or 225510
carry 11 1
An integer decimal number can be converted to a cor-
responding octal number by repeatedly dividing by 8
and noting the remainder at each stage, as shown below
Problem 10. Perform the binary addition: for 49310 .
1011101 + 1100001 + 110101
8 493 Remainder
1011101 8 61 5
1100001
+ 110101 8 7 5
sum 11110011 0 7
carry 11111 1
7 5 5

Now try the following exercise


Thus 49310 = 7558
The fractional part of a decimal number can be converted
Exercise 40 Further problems on binary to an octal number by repeatedly multiplying by 8, as
addition shown below for the fraction 0.437510
Perform the following binary additions:
0.4375 3 8 5 3. 5
1. 10 + 11 [101]
2. 101 + 110 [1011] 0.5 385 4. 0
3. 1101 + 111 [10100]
.3 4
4. 1111 + 11101 [101100]
5. 110111 + 10001 [1001000] For fractions, the most significant bit is the top integer
6. 10000101 + 10000101 [100001010] obtained by multiplication of the decimal fraction by
8, thus,
7. 11101100 + 111001011 [1010110111]
0.437510 = 0.348
8. 110011010 + 11100011 [1001111101]
9. 10110 + 1011 + 11011 [111100] The natural binary code for digits 0 to 7 is shown
in Table 10.1, and an octal number can be converted
10. 111 + 10101 + 11011 [110111] to a binary number by writing down the three bits
11. 1101 + 1001 + 11101 [110011] corresponding to the octal digit.
12. 100011 + 11101 + 101110 [1101110] Thus 4378 = 100 011 1112
and 26.358 = 010 110.011 1012
Binary, octal and hexadecimal 91

Table 10.1 Thus 0.5937510 = 0.468


Octal digit Natural From Table 10.1, 0.468 = 0.100 1102
binary number i.e. 0.59375 10 = 0.100 112
0 000
Problem 13. Convert 5613.9062510 to a binary
1 001 number, via octal.
2 010
The integer part is repeatedly divided by 8, noting the
3 011 remainder, giving:
4 100
5 101 8 5613 Remainder
8 701 5
6 110
8 87 5
7 111 8 10 7
8 1 2
The ‘0’ on the extreme left does not signify anything, 0 1
thus 26.358 = 10 110.011 1012 1 2 7 5 5
Conversion of decimal to binary via octal is demon-
strated in the following worked problems.
This octal number is converted to a binary number,
Problem 11. Convert 371410 to a binary number, (see Table 10.1).
via octal.

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

In Problems 1 to 3, convert the decimal numbers = 1 × 161 + 10 × 1


given to binary numbers, via octal.
= 16 + 10 = 26
1. (a) 343 (b) 572 (c) 1265
(a) 1010101112 (b) 10001111002 i.e. 1A16 = 2610
(c) 100111100012
Similarly, 2E16 = 2 × 161 + E × 160
2. (a) 0.46875 (b) 0.6875 (c) 0.71875
= 2 × 161 + 14 × 160
(a) 0.011112 (b) 0.10112
(c) 0.101112 = 32 + 14 = 4610

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

(a) 7A16 = 7 × 161 + A × 160 = 7 × 16 + 10 × 1


10.4 Hexadecimal numbers = 112 + 10 = 122
The hexadecimal system is particularly important in Thus 7A16 = 12210
computer programming, since four bits (each consist-
ing of a one or zero) can be succinctly expressed using (b) 3F16 = 3 × 161 + F × 160 = 3 × 16 + 15 × 1
a single hexadecimal digit. Two hexadecimal digits rep- = 48 + 15 = 63
resent numbers from 0 to 255, a common range used,
for example, to specify colours. Thus, in the HTML Thus 3F16 = 6310
language of the web, colours are specified using three
Binary, octal and hexadecimal 93

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

23 10111 27 17 most significant bit 1 A least significant bit


24 11000 30 18
Hence 2610 = 1A16
25 11001 31 19
26 11010 32 1A Similarly, for 44710

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

Hence 10810 = 6C16 Problem 20. Convert the following binary


numbers into their hexadecimal equivalents:
Problem 19. Convert the following decimal (a) 110101102 (b) 11001112
numbers into their hexadecimal equivalents:
(a) 16210 (b) 23910
(a) Grouping bits in fours from the right gives:
1101 0110
and assigning hexadecimal symbols
(a) 16 162 Remainder D 6
16 10 2 5 216 to each group gives as above from Table 10.2.
0 10 5 A16
Thus, 110101102 = D616
A 2
(b) Grouping bits in fours from the right gives:
Hence 16210 = A216 0110 0111
and assigning hexadecimal symbols
(b) 16 239 Remainder 6 7
to each group gives as above from Table 10.2.
16 14 15 5 F16
0 14 5 E16 Thus, 11001112 = 6716
E F
Problem 21. Convert the following binary
Hence 23910 = EF16
numbers into their hexadecimal equivalents:
(a) 110011112 (b) 110011110 2
Now try the following exercise
(a) Grouping bits in fours from the right gives:
Exercise 42 Further problems on 1100 1111
and assigning hexadecimal symbols
hexadecimal numbers C F
to each group gives as above from Table 10.2.
In Problems 1 to 4, convert the given hexadecimal
numbers into their decimal equivalents. Thus, 110011112 = CF16
1. E716 [23110 ] 2. 2C16 [4410 ]
(b) Grouping bits in fours from the right gives:
3. 9816 [15210 ] 4. 2F1 16 [75310 ] 0001 1001 1110
and assigning hexadecimal
1 9 E
Binary, octal and hexadecimal 95

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

i.e. 6CF316 = 1101100111100112


Now try the following exercise

Problem 22. Convert the following hexadecimal


numbers into their binary equivalents: Exercise 43 Further problems on
(a) 3F16 (b) A616 hexadecimal numbers
In Problems 1 to 4, convert the given binary
(a) Spacing out hexadecimal digits gives: numbers into their hexadecimal equivalents.
3 F
and converting each into binary 1. 110101112 [D716 ]
0011 1111
gives as above from Table 10.2.
2. 111010102 [EA 16 ]
Thus, 3F16 = 1111112
3. 100010112 [8B16 ]
(b) Spacing out hexadecimal digits gives:
A 6 4. 101001012 [A516 ]
and converting each into binary
1010 0110 In Problems 5 to 8, convert the given hexadecimal
gives as above from Table 10.2. numbers into their binary equivalents.
5. 3716 [1101112]
Thus, A616 = 101001102
6. ED16 [111011012]

Problem 23. Convert the following hexadecimal 7. 9F16 [100111112]


numbers into their binary equivalents:
8. A2116 [1010001000012]
(a) 7B16 (b) 17D16
Revision Test 3

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)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy