Ch-1 Data Representation
Ch-1 Data Representation
The methods used to represent digital data (or information stored in computers) are known as
data representation. The data may contain digits, alphabets or special characters which are
converted to binary form understandable by the computer.
Number Systems:
1. The technique to represent and work with numbers by using symbols is called number
system.
2. They are classified into two types:
a) Non positional (or Non-Weighted) number systems such as Roman number system,
Excess-3 Code etc.
b) Positional (or Weighted) number systems
Positional (or Weighted) Number Systems:
1. They use well defined symbols called digits.
2. The magnitude of a number in these systems can be found using the following
parameters:
a) Absolute or Face or True value – is the magnitude or actual value of a digit in a
number. For example the digit 4 in 745 has an absolute value of 4.
b) Place or Positional value or Weight – refers to the position of the digit in a number.
For example 101, 2–1, etc.
c) Base or Radix – of a number system is defined as the total number of distinct
symbols or digits available to represent a number in the number system.
3. There are mainly four types of the number systems in a computer:
4. Binary Number System, Octal Number System and Hexadecimal Number System are
collectively known as Digital Number System.
CN XI – SR Page 1
Number Systems Conversion
1) Other Base System with Fractional Part to Decimal:
Steps:
(i) Each digit of the integer part is multiplied with positive weights (from right to left),
while the fractional part is multiplied with negative weights (left to right) to get the
equivalent decimal values.
(ii) Add the decimal values to obtain the equivalent decimal number.
(iii) In general, a n – digit base r number (N)r =(dn –1 dn–2...d1d0 .d–1d–2…d–n)r, is
converted to its decimal equivalent by:
dn –1×rn–1 + dn –2×rn–2... + d1×r1 + d0×r0 + d1×r-1 + d1×r-2 +…..+ dn×rn
a) Binary Decimal
Example 1: Convert (1101.101)2 into (?)10
Solution:
1101.101
1 x 2–3 = 0.125
0 x 2–2 = +0.0
1 x 2–1 = +0.5
1 x 20 = +1
0 x 21 = +0
1 x 22 = +4
1 x 23 = +8
= 13.625
(1101.101)2 = (13.625)10
b) Octal Decimal
Example 2: Convert (24.6)8 into (?)10
Solution:
24.6
6 x 8–1 = 0.75
4 x 80 = +4
2 x 81 =+16
= 20.75
(24.6)8 = (20.75)10
c) Hexadecimal Decimal
Example 3: Convert (1A3.08)16 into (?)10
Solution:
1A3.08
8 x 16–2 = 0.03125
CN XI – SR Page 2
0 x 16–1 = + 0.00000
3 x 160 = + 3
10 x 161 = +160
1 x 162 = +256
419.03125
(1A3.08)16 = (419.03125)10
a) Decimal Binary
Example 1: Convert (41.375)10 into (?)2
Solution:
(41.375)10 = (101001.011)2
CN XI – SR Page 3
(14.8125)10 = (1110.1101)2
b) Decimal Octal
Example 3: Convert (174.375)10 into (?)8
Solution:
(174.375)10 = (256.3)8
Example 4: Convert (540.125)10 into (?)8
Solution:
(540.125)10 = (1034.1)8
d) Decimal Hexadecimal
Example 5: Convert (214.03125)10 into (?)16
Solution:
CN XI – SR Page 4
3) Any Base System with Fractional Part to Other Base System:
a) Binary Octal
Steps:
(i) Divide the binary digits into groups of three bits starting at the LSB (for
the integer part) and/or MSB (for the fraction).
(ii) Add 0’s to the left (for an integer) or right (for a fraction), to fill an
incomplete 3 bit group.
(iii) Convert each group into its octal equivalent.
Example 1: (101110.0101)2 = (?)8
Solution:
CN XI – SR Page 5
(11001110110.1100001)2 = (676.C2)16
c) Octal Binary
Steps:
(i) Convert each octal digit to a 3-digit binary number.
(ii) Combine all the resulting binary groups (of 3 digits each) into a single
binary number.
Example 4: (367.42)8 = (?)2
Solution:
(367.42)8 = 3 6 7 . 4 2
(367.42)8 = (011110111.100010)2
d) Hexadecimal Binary
Steps:
(i) Convert each hexadecimal digit to a 4-digit binary number.
(ii) Combine all the resulting binary groups (of 4 digits each) into a single
binary number.
Example 5: (3A6.F)16 = (?)2
Solution:
(3A6.F)16 = 3 A 6 . F
e) Octal Hexadecimal
Steps:
(i) Convert octal number to binary.
(ii) Convert binary number to hexadecimal.
Example 6: (175.3)8 = (?)16
Solution:
CN XI – SR Page 6
(175.3)8 = 1 7 5 . 3
= (001111101.010)2
binary positions 8 4 2 1 8 4 2 1 8 4 2 1 . 8 4 2 1
0 7 D 4
(175.3)8 = (7D.4)16
f) Hexadecimal Octal
Steps:
(i) Convert hexadecimal number to binary.
(ii) Convert binary number to octal.
Example 7: (9AF.4)16 = (?)8
Solution:
(9AF.5)16 = 9 A F . 4
(9AF.5)8 = (4657.24)16
Binary Arithmetic
a) Addition:
Augend 0 0 1 1
Addend +0 +1 +0 +1
Sum 0 1 1 10
carry
CN XI – SR Page 7
Steps:
(i) Add the digits (from right) as in base 10.
(ii) If sum exceeds the range (0 – 1), then subtract base value i.e. 2 from the sum
and write the result.
(iii) On subtracting base value (i.e. 2), 1 is carried over to the next higher bit.
Example: Perform the following binary additions:
i) 11011.11 + 10011.10
ii) 110110 + 101011
iii) 1101101 + 101101
Solution:
Steps:
(i) Borrow 1 from the higher significant bit, and decrease its respective value by 1.
(ii) On borrowing 1, add base value i.e. 2 to the minuend bit to get a sum.
(iii) Subtract subtrahend from the sum to get the result.
Example: Do the following binary subtractions:
i) 110.01 – 100.1
ii) 10101 – 1111
iii) 11011.011 – 10001.0011
Solution:
CN XI – SR Page 8
c) Multiplication:
Multiplicand 0 0 1 1
Multiplier x0 x1 x0 x1
Product 0 0 0 1
Example 1: Multiply 111 by 101
Solution:
d) Division:
Dividend / Divisor = Quotient
0 / 1 =0
1 / 1 =1
CN XI – SR Page 9
Example 2: Divide 101011 by 1000
Solution:
Octal Arithmetic
a) Addition:
Augend 0 0 1 1
Addend +0 +2 +6 +7
Sum 0 2 7 10
Steps:
i) Add the digits (from right) as in base 10.
ii) If sum exceeds the range (0 – 7), then subtract base value i.e. 8 from the sum
and write the result.
iii) On subtracting base value (i.e. 8), 1 is carried over to the next higher digit.
Example 1: Do the following octal additions:
i) 62 + 47
ii) 126 + 357
iii) 567 + 243
Solution:
i) ii) iii)
CN XI – SR Page 10
Example: Do the following octal subtractions:
i) 62 – 47
ii) 723 – 264
iii) 1204 – 743
Solution:
i) ii) iii)
Hexadecimal Arithmetic
a) Addition:
Augend 1 1 1
Addend +1 +9 +15
Sum 2 A 10
Steps:
i) Add the digits (from right) as in base 10.
ii) If sum ranges outside (0 – 15), then subtract base value i.e. 16 from the sum
and write the result.
iii) On subtracting base value (i.e. 16), 1 is carried over to the next higher digit.
CN XI – SR Page 11
ii) On borrowing 1, add base value i.e. 16 to the minuend bit to get a sum.
iii) Subtract subtrahend from the sum to get the answer.
Example: Do the following hexadecimal subtractions:
i) 2C0 – 1A6
ii) 974B – 587C
Solution:
i) ii)
r’ s Compliment Representation:
1. In r’s compliment representation, r represents the base or radix. It is of two types:
i) (r – 1)’s complement
ii) r’s compliment
2. The complement representations based upon the radix or base of different number
systems are:
i) 1’s complement, 2’s complement (for binary number system)
ii) 7’s complement, 8’s complement (for octal number system)
iii) 9’s complement, 10’s complement (for decimal number system)
iv) 15’s complement, 16’s complement (for hexadecimal number system)
3. To determine the (r – 1)’s complement, subtract the given number from the maximum
number in the given base.
4. To determine the r’s complement, add 1 to the (r – 1)’s complement of given number.
CN XI – SR Page 12
iv) If the sum has a final carry over, then the answer is obtained by adding 1 to the
remaining digits of sum.
v) If the sum has no final carry over, then write its 1’s or 7’s or 9’s or 15’s complement
(i.e. re–compliment it) and prefix a negative sign to it to get the answer.
CN XI – SR Page 13
Example 4: Find 2C016 – 1A616 by 15’s compliment method.
Solution:
CN XI – SR Page 14
Solution: R.W
Example 2: Express –25 in sign magnitude form given a word size of 8-bits.
Solution:
Example 3: Determine the decimal integer represented by sign magnitude binary integer
(01000001)2, given a word size of 8 bits.
Solution:
CN XI – SR Page 16
1’s Compliment Representation:
In this representation,
i) Every positive integer is represented in its true form, by its binary equivalent. For
e.g. +10 is represented as 1010.
ii) Every negative integer is represented by its 1’s compliment binary form.
iii) Total numbers represented by an N–bit word using 1’s compliment representation
are 2N – 1.
Note:
There are two representations of 0 in signed magnitude and 1’s complement
representations.
a) (0000 0000)2 (+0) and (1000 0000)2 (–0) ( for signed magnitude)
b) (0000 0000)2 (+0) and (1111 1111)2 (–0) ( for 1’s complement)
CN XI – SR Page 17
vi) In general for N bits word size, the maximum positive number that can be
represented using 2’s complement form is + (2N – 1 – 1) and the maximum
negative number that can be represented using 2’s complement form is – (2N – 1).
Example: Express -25 in 8-bit 2’s compliment form.
Solution:
iii) Based on the word length, the size of the various parts are:
Word Sign bit Integral part Fractional part
8 – bit 1 4 – bit 3 – bit
16 – bit 1 9 – bit 6 – bit
32 – bit 1 23 – bit 8 – bit
CN XI – SR Page 18
Example 1: Express (4.5)10 in 8-bit fixed point notation.
Solution:
(4.5)10 = (100.1)2
=00100.100
S I F
Example 2: Express – (43.625)10 in 16-bit fixed point notation.
Solution:
– (43.625)10 = (101011.1010)2
= 1000101011.101000
2. Floating Point Representation:
i) It allows varying number of bits for the integer or fractional parts.
ii) It uses scientific (or exponential) notation to represent the real numbers.
iii) A floating point number is expressed in scientific notation as: M x rE,
Here, M denotes the mantissa (or significand) that represents fixed point number
r denotes the radix or base
E denotes the exponent, an integer value that designates the position of the radix
point
iv) Decimal floating point numbers are expressed in the form: mantissa × 10exponent
Example: 325.123 = 3.25123 x 102 = 0.325123 x 103
0.000000245 = 0.245 x 10-6 = 2.45 x 10-7
v) Binary floating point numbers are expressed in the form: mantissa × 2exponent
Example: 1000.0101 = 1.0000101 x 23 = 0.10000101 x 24
vi) A floating-point number is said to be in normalized scientific form if and only if there
is a single non-zero digit to the left of the radix point. For example 1.234 x 108,
5.6789 x 10-15
CN XI – SR Page 19
(10110.11)2 = 10110.11 x 20 = 10110.11 x 20 x 24
= 1.011011 x 24 (normalized form)
Encoding Characters:
Characters are encoded by a special group of symbols called ‘CODES’. The various types of
codes are:
CN XI – SR Page 21