COG Chapter 1
COG Chapter 1
COG Chapter 1
Radix Conversions
Conversion of Decimal System to other Systems
Character Codes (Alphanumeric Representation)
Unit 1
Representation of Information
Learning Objectives
After reading this unit you should appreciate the following:
Number System
Floating Point Representation
Integer Representation
Character Codes
Top
Number System
Number system is a set of symbols to form numbers. Numbers are expressed by a string of digit symbols.
To determine the quantity that a number represents is determined by multiplying each digit by a power of
base called radix represented by ‘r’ and then forming the sum of all digits. For example, 410 may be
represented in decimal number as
4 100+110+ 01
= 400 + 10
= 410
This number system utilizes the base 10 (the 10 symbols are 0,1,2,3 to 9). Various other numbers systems
use different base. For example the binary number system uses the base 2, the octal 8 i.e. 0- 7 and
hexadecimal 16 i.e. 0-9 and A-F. The sum of the weighted digits is formed for the conversion of a number
in base ‘r’ into the familiar decimal system. Conversion of a decimal integer into a base ‘r’ representation is
performed by, successive divisions by ‘r’ and accumulation of the remainders. The conversion of a decimal
fraction to base ‘r’ representation is accomplished by successive multiplication’s by ‘r’ and accumulation of
the integer digits so obtained. This is shown below.
The binary representation of decimal numbers up to 15 is
2 ARTIFICIAL INTELLIGENCE
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
35 10 0011 43 23
100 110 0100 144 64
255 1111 1111 377 FF
Radix Conversions
A number in any radix (base) is very much convertible into any other radix. A binary number system has
radix-2 consisting of only two digits, decimal system has a radix-10 consisting of digits from 0-9 and octal
system has a radix-8 consisting of digits from 0-7. Similarly a hexadecimal system has radix-16 consisting
of digits from 0-9 and from A to F.
Top
The following method is employed to convert decimal system into other systems:
WHAT IS ARTIFICIAL INTELLIGENCE 3
Example 1.1
Fraction Conversion
This method is employed to convert the fraction part of the decimal system to other systems.
1. Multiply fraction to be converted of proposed system with radix. Let the fraction part of this
product be F1 and I1 resulting integer.
2. Multiply the resulting fraction part F1 with the radix again, we’ll get F2 and I2.
3. Repeat the above steps until the fraction part disappears.
4. The required fraction number in the required system with radix R would be I 1 I2 I3 ...... In
Example 1.2
Convert the decimal number 41.125 into binary. Here we first convert the integer part 41 into binary
by using remainder method. It is shown as follows:
41 divide by 2 remainder 1 (Quotient 20)
20 divide by 2 remainder 0 (Quotient 10)
4 ARTIFICIAL INTELLIGENCE
Example 1.3
Example 1.4
Find the binary equivalent of (23.8125) 10. First we find the binary equivalent of integer part 23 as
follows:
WHAT IS ARTIFICIAL INTELLIGENCE 5
Example 1.5
Convert decimal number 12110 into octal. This process is shown as follows:
divide 12110 by 8 remainder 6 (Quotient 1513)
divide 1513 by 8 remainder 1 (Quotient 189)
divide 189 by 8 remainder 5 (Quotient 23)
divide 23 by 8 remainder 7 (Quotient 2)
divide 2 by 8 remainder 2 (Quotient 0)
hence (12110)10 = (27516)8
Example 1.6
Convert decimal number 755.9375 to its hexadecimal equivalent. The integer part 755 can be
converted as follows:
755 divide by 16 remainder 3 (Quotient 47)
47 divide by 16 remainder 15 (i.e.F) (Quotient 2)
2 divide by 16 remainder 2 (Quotient 0)
hence (755)10 = (2F3)16
Now we convert the fraction part .9375
0.9375
Fraction 16 Integer part=15 i.e. F
15.0000
Fraction 0.0000
Hence (0.9375)10 = (F)16
therefore (755.9375)10 = (2F3.F)16
Example 1.7
Convert the binary number (1010.011)2 into decimal. The decimal equivalent is
23 1+22 0+21 1+20 0+2-1 0+2-2 2-3 1=10.375
8 n a n 8 n 1 a n 1 ........8 0 a0 8 1 a 1 ........8 m a m
Example 1.8
Convert the number (550.4) 8 into decimal. The decimal equivalent for this number is
8 2 5 8 1 5 8 0 0 8 1 4
320 40 0 0.5
( 360.5 )10
16 n a n 16 n 1 a n 1 .....16 0 a 0 16 1 a 0 .....16 m a m
Example 1.9
Convert the Hexadecimal number 2F3.F2 into its equivalent decimal number. From the above
formula, we get
8 ARTIFICIAL INTELLIGENCE
2F 3.F 2 16 16 2 2 F 16 1 3 16 .0 16 1 F 16 2 2
15 2
512 15 16 3
16 256
755.9375 10
Example 1.10
Example 1.11
Example 1.12
Convert octal number 552.47 into binary equivalent. On replacing each octal digit by its
corresponding three bits binary number, we get
(552.47)8 = (101 101 010.100 111) 2
WHAT IS ARTIFICIAL INTELLIGENCE 9
Example 1.13
Complements
Complements are the operations employed for the simplification of the subtraction and logical
manipulation as well as for negative numbers representation. In a base-r system, two types of complements
are possible: (i) the r’s complement and (ii) (r-1)’s complement. For example for binary numbers there are
2’s and 1’s complements and decimal numbers have 10’s and 9’s complements.
i) The r’s Complement: The r’s complement of a positive number N is defined as r n-N. Where r is the
base of the number, N, and n is the number of digits in integer part of N.
Example 1.14
Where r is the base of number N, n is the no. of digits in integer part and m is the number of
digits in fraction part.
If there is no fraction part then the r 1 1 , complement = r n 1 – N .
Example 1.15
The 1’s complement of 111 .01 2 2 2 111 .01 111 .11 111 .01 000.10
3 2
From the above example it is clear that 9’s complement can be obtained by subtracting each digit
from 9. Similarly, 1’s complement of a binary number can be obtained by subtracting each digit from 1.
Example 1.16
7345
+ 4568
11913
discard the end carry
Hence S-T=1913
Example 1.17
0432
+ 8766
9198
Since no end carry is here hence
S-T= (10’s complement of 9198)
WHAT IS ARTIFICIAL INTELLIGENCE 11
= – 0802
Example 1.18
0432
+ 8765
9197
Since no end carry to here, hence
S-T= - (9’s complement of 1997)
= – 0802
Example 1.19
1. Convert the number (243.468)10 into its binary, octal and hexadecimal equivalent.
2. Convert the binary number (101101.101101)2 into octal and hexadecimal number system.
3. The roots of the quadratic equation x 2 – 12x 37 0 are 5 and 8. Find the base system in which
this equation is written.
4. Subtract 1101 from 0111 using (i) 2’s complement (ii) 1’s complement.
If your answers are correct, then proceed to the next section.
Top
The first 32 characters and the last character are control characters. Usually, they are not displayed. However, some versions of C (some computers)
support special graphics characters for these ASCII values. For example, 001 may represent the character 002 may represent
and so on.
16 bit
0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1
= 511.984375
and Minimum number = 000000000.000001
= 2 6
= 0.015625
This range is quite inadequate even for simple arithmetic computations.
Normalization
Floating-point representation has inherent demerits in the sense that the same number can be represented in
many ways. For example 3.0 1014 0.3 10 15 , 3000 10 11 and 0.03 10 16 , all represents the same
number. This necessitates a representation that is unique or normal for m and can be adopted by each
system. The mantissa is said to be normalized if the digits to the right of radix point is not zero, that is, no
lending zero appear in the magnitude part of the number. Hence, for above number 0.31015 is the normal
for m or we can say that 0.31015 is a normalized floating point number.
8 e m
WHAT IS ARTIFICIAL INTELLIGENCE 15
In a normalized floating point number, the leftmost bit of significant (m) is always 1, so, its storage is
not required. The exponent is represented as 8-bit excess 127 code. Hence the actual mantissa is 1.m and
actual exponent is e-127. The base 10 of the number is 2. Hence the real number a in IEEE 1 st standard is
given by
a 1 s 2 e 127 1.m
provided = 0<E<255
0<e<EST
Example 1.20
The magnitudes for non-zero floating point numbers in the format ranges from 2 -126 (1.0) to 2+127 (2-2-
23
) that is, from 1.18 10-38 to 3.40 1038 approximately. On the contrary, the magnitudes for fixed point
binary formats for integers ranges from 1 to 2 31-1 i.e. 2.15 109 approximately. The
64-bit version of IEEE 754 standard is an extension to 32-bit. It employs an 11-bit exponent and
52-bit mantissas and the number it defines is
a= (-1)s 2e-1023 (1.m)
a=(-1) s 2e-1027 (1.m)
where 0<e<2047.
Summary
Self-assessment Questions
1. (11011.1001)2 = (_________________________________________)8
2. ASCII stands for________________________________________
Answers
1. Shl
2. 6
Answers
1. False
2. True
1. The channel through which CPU and memory accomplish using ____________.
2. Mirco-operation for adding content of memory location 5 to the content of register R1 is
____________.
WHAT IS ARTIFICIAL INTELLIGENCE 17
1. Accumulator is a decoder.
2. Control unit is a part of ALU.
Detailed Questions
iv. 124.43-876.85
9. Write first 20 decimal numbers in base 5.
10. Fill in the blanks:
i. The 10’s complement of (5432)11 is________________________