Tut11 Number System - Exercises

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Number systems

Example 1.1.1: Find the magnitude of 245.378

D = 2.82 + 4.81 + 5.80 + 3.8-1 + 7.8-2

= 165.48437510

A binary (base=2) number system is a special case of the positional number system in which the allowable
digits are 0 and 1 that are called ìbitsî. The leftmost digit of a binary number is called the most significant bit
(MSB) and the rightmost is called the least significant bit (LSB). Because the base of binary numbers is two,
i
bit bi is associated with weight 2 .

Example 1.1.2: Magnitude of Binary number


110100102 =1.27 +1.26 +0.25 +1.24 +0.23 +0.22 +1.21 +0.20

1101.00112 =1.23 +1.22 +0.21 +1.20 +0.2-1 +0.2-2 +1.2-3 +1.2-4

If the base of a number system is larger than ten, the digits exceeding 9 are expressed using alphabet letters as
a convention. For example, hexadecimal number system uses 1-9 and A-F; base-32 number system uses 1-9
and A-V. This example is shown in Table 1. One may then wonder how large-base number systems such as a
base-64 are expressed. Fortunately, we rarely use such a high-base number system because we find no real
advantages of using them in applications. Moreover, we can always convert them from any high-base number
system to a lower base number system, which is the subject of the next section.
Table 1. Decimal, binary, hexadecimal, and base-32 Number Systems

Decimal Binary Octal Hexadecimal Base-32


0 00000 0 0 0
1 00001 1 1 1
2 00010 2 2 2
3 00011 3 3 3
4 00100 4 4 4
5 00101 5 5 5
6 00110 6 6 6
7 00111 7 7 7
8 01000 10 8 8
9 01001 11 9 9
10 01010 12 A A
11 01011 13 B B
12 01100 14 C C
13 01101 15 D D
14 01110 16 E E
15 01111 17 F F
16 10000 20 10 G
17 10001 21 11 H
18 10010 22 12 I
19 10011 23 13 J
20 10100 24 14 K
21 10101 25 15 L
22 10110 26 16 M
23 10111 27 17 N
24 11000 30 18 O
25 11001 31 19 P
26 11010 32 1A Q
27 11011 33 1B R
28 11100 34 1C S
29 11101 35 1D T
30 11110 36 1E U
31 11111 37 1F V
Example 1.2.1: Binary to hexadecimal or octal conversion

Example 1.2.2: Octal to hexadecimal or vice versa

We have seen that the conversion between numbers with power of radix 2 can be readily achieved through
binary expression and regrouping of bits. This convenience led to utilization of hexadecimal (or octal)
numbers in representing binary numbers for many computer architecture related issues. For example, the
instruction LDAA (Load Accumulator A) of 68HC11 is encoded

as the binary number 100001102 , but for convenience of writing and reading it is usually

expressed in hexadecimal 8616 , from which we save time and spaces. Very often, hexadecimal,

octal, and binary numbers are interchangeably used in the computer architecture or microprocessor related
fields.

Example 1.3.2: Integer expressions of positional numbers


From Example 1.3.2, notice that if the last expression is divided by 10 the remainder is the least significant
digit 2 and the quotient is ((510+ 4)10+ 3) . The next significant digit can be

obtained by dividing 53510 again by 10. Due to this relation, the conversion to an arbitrary base

number can be obtained by repeated division of quotient and collection of remainders. A simple hand-
calculation method can be devised using the above relation. Let's express the integer division by the
following form.

Using this expression, Example 1.3.3 shows conversion from a decimal to a binary.

Example 1.3.3: Convert 17910 to a binary.

The final conversion result reads

179 = 10110011 .
10 2

It should be noted that the above method can be extended to conversion of any other base. For
example, consider that we wish to convert a hexadecimal number to a base-5 number. Then, the
base-5 number can be directly converted by repeated division by 5 and collecting remainders.
However, this direct division means, you must divide the base-16 number by 5, which is not
simple because we are only used to decimal numbers. Thus, it is essentially wise to first convert
the hexadecimal to a decimal, and then convert it to base-5.

Similarly to the expression of integer part in Eq. (3), the fractional part can be written in the
following form:

Note that multiplying b to F in Eq. (4) produces d -1 as a part of the product. This representation
of number system is illustrated using Example 1.3.3.
Example 1.3.3: Fraction expression of positional numbers
Example 1.3.4: Convert a decimal number 0.625 to binary.

Example 1.3.4: Decimal to base-x conversion: Convert 0.710 to a binary.


Table 2. 4-bit Numbers in Different Signed Systems
Decimal 2’s 1’s Signed
Complement complement Magnitude
-8 1000 - -
-7 1001 1000 1111
-6 1010 1001 1110
-5 1011 1010 1101
-4 1100 1011 1100
-3 1101 1100 1011
-2 1110 1101 1010
-1 1111 1110 1001
0 0000 1111 or 0000 1000 or 0000
1 0001 0001 0001
2 0010 0010 0010
3 0011 0011 0011
4 0100 0100 0100
5 0101 0101 0101
6 0110 0110 0110
7 0111 0111 0111
Exercise 1: Decimal – Binary
Convert these IP addresses from dotted decimal notation to binary notation:
a. 123.160.16.178
b. 221.255.31.117

Exercise 2: Binary – Decimal


Convert these IP addresses from binary notation to dotted decimal notation:
a. 11010000.01010000.01011100.00010010(2)
b. 11110100.00110010.00001110.11010001(2)

Exercise 3:
Convert 120(10) to binary

Convert 1010101(2) to decimal

Convert 1023(10) to binary

Convert 10001110(2) to decimal, octal and hexadecimal.

Convert the following to binary form:


810
4010
10110

Convert the following to decimal form:


11002
001100102
011112

Exercise 4: Binary – Octal


Convert binary to octal number and octal to binary number
a. 11010000.01010000.01011100.00010010(2)
b. 11110100.00110010.00001110.11010001(2)
c. 1456762(o)
d. 54278423(o)

Exercise 5: Binary – HexaDecimal


a. 11010000.01010000.01011100.00010010(2)
b. 11110100.00110010.00001110.11010001(2)
c. 56A5DB38929(H)
d. F56EFFE7667(H)
e. 47F8D2EE67F(H)

You might also like