0% found this document useful (0 votes)
14 views21 pages

Ch-1 Data Representation

The document discusses data representation methods in computers, focusing on number systems and their conversions. It outlines positional and non-positional number systems, detailing binary, octal, decimal, and hexadecimal systems, along with conversion techniques between these bases. Additionally, it covers binary, octal, and hexadecimal arithmetic operations including addition, subtraction, multiplication, and division.

Uploaded by

anirajaniraj1
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)
14 views21 pages

Ch-1 Data Representation

The document discusses data representation methods in computers, focusing on number systems and their conversions. It outlines positional and non-positional number systems, detailing binary, octal, decimal, and hexadecimal systems, along with conversion techniques between these bases. Additionally, it covers binary, octal, and hexadecimal arithmetic operations including addition, subtraction, multiplication, and division.

Uploaded by

anirajaniraj1
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/ 21

Data Representation (Chap – 1)

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:

S No. Number System Base Digits or Symbols Example


1 Binary 2 0,1 (10101)2
2 Octal 8 0 to 7 (6270)8
3 Decimal 10 0 to 9 (6921)10
Hexadecimal 0 to 9, Letters used : A – F where
4 16 (9FA5)16
(Alpha Numeric) A=10, B=11, C=12, D=13, E=14, F=15
For example (25.32)10 = 2 X 101 + 5 X 100 + 3 X 10–1 + 2 X 10–2
↑ ↑
MSD LSD
Digit Position 101 100 . 10–1 10–2
Face value 2 5 . 3 2
Positional value 20 5 . 0.3 0.02

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

2) Decimal to Other Base System with Fractional Part:


Steps:
(i) Separate the integral and the fractional parts of the decimal number.
(ii) The integral part is divided repeatedly by the target base b and the successive
remainders are noted after each division (in a separate column) until the quotient
becomes zero.
(iii) Write the noted remainders in the reverse order (from bottom to top). The last
remainder thus obtained will be the Most Significant Digit (MSD) of the new base
number.
(iv) The fractional part is multiplied repeatedly by the target base b till the fractional
part becomes 0 or the fractional part starts repeating. The integer part (carry) of
the successive products are written in the same order (from top to bottom) to get
equivalent number in the target base.

a) Decimal  Binary
Example 1: Convert (41.375)10 into (?)2
Solution:

(41.375)10 = (101001.011)2

Example 2: Convert (14.8125)10 into (?)10


Solution:

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:

(214.03125)10 = ({13}6.08)16 = (D6.08)16

Example 6: (153.625)10 = (?)16


Solution:

(675.625)10 = (9{12}. {10})16 = (9C.A)16

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:

 (101110. 0101)2 = (56.24)8


b) Binary  Hexadecimal
Steps:
(i) Divide the binary digits into groups of four 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 4 bit group.
(iii) Convert each group into its hexadecimal equivalent.
Example 2: (11010110. 0101)2 = (?)16
Solution:

 (11010011. 0101)2 = (D6.5)16


Example 3: (11001110110.1100001)2 = (?)16
Solution:
8421 84218421 8421 8421
0110 0111 0110 .1100 0010
6 7 6 . C 2

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

binary positions  4 2 1 421 421 421 421

011 110 111.100 010

(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

binary positions  8 4 2 1 8 4 2 1 8 4 2 1 8421

0011 1010 0110.1111


(3A6.F)16 = (001110100110.1111)2

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

binary positions  4 2 1 421 421. 421

001 111 101 .010

= (001111101.010)2
binary positions  8 4 2 1 8 4 2 1 8 4 2 1 . 8 4 2 1

0000 0111 1101 . 0100

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

binary positions  8 4 2 1 8 4 2 1 8 4 2 1 8421

1001 1010 1111.0101


= (100110101111.0101)2

binary positions  4 2 1 421 421 421 . 421 421

100 110 101 111 .010 100


4 6 5 7 . 2 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:

b) Subtraction (Direct Method):


borrow
Minuend 0 1 1 10
Subtrahend –0 –0 –1 –1
Difference 0 1 0 1

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:

Example 2: Multiply 11001 x 1101


Solution:

d) Division:
Dividend / Divisor = Quotient
0 / 1 =0
1 / 1 =1

Example 1: Divide 11001 by 101


Solution:

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)

b) Subtraction (Direct Method):


Steps:
i) Borrow 1 from the higher significant digit, and decrease its respective value by 1.
ii) On borrowing 1, add base value i.e. 8 to the minuend bit to get a sum.
iii) Subtract subtrahend from the sum to get the answer.

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.

Example: Do the following hexadecimal additions:


i) Find 4F + B2
ii) FACE + 8973
Solution:
i) ii)

b) Subtraction (Direct Method):


Steps:
i) Borrow 1 from the higher significant digit, and decrease its respective value by 1.

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.

(r – 1)’s Compliment Subtraction Method:


Steps:
i) Add 0’s to the left or right (if required) to the subtrahend to make its number of digits
equal to that of minuend.
ii) Convert the subtrahend to its (r – 1)’s compliment by subtracting each digit from 1(for
binary), 7 (for octal), 9 (for decimal) or F (for hexadecimal).
iii) Add this to the minuend.

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.

Example 1: Find 111 – 101 by 1’s compliment method.


Solution:
R.W

Example 2: Find 101 – 111 by 1’s compliment method.


Solution: R.W

Example 3: Find 628 – 478 by 7’s compliment method.


Solution:

CN XI – SR Page 13
Example 4: Find 2C016 – 1A616 by 15’s compliment method.
Solution:

r’s Compliment Subtraction Method:


Steps:
i) Add 0’s to the left or right (if required) to the subtrahend to make its number of digits
equal to that of minuend.
ii) Convert the subtrahend to its r’s compliment which is (r – 1)’s compliment (i.e. 1’s or
7’s or 9’s or 15’s) + 1.
iii) If the sum has a final carry over, then drop the carry over to get the answer.
iv) If the sum has no final carry over, then write its 2’s or 8’s or 10’s or 16’s complement
(i.e. re–compliment it, add 1 to it) and prefix a negative sign to it to get the answer.

Example 1: Find 111 – 101 by 2’s compliment method.


Solution:
R.W

Example 2: Find 101 – 111 by 2’s compliment method.

CN XI – SR Page 14
Solution: R.W

Example 3: Find 628 – 478 by 8’s compliment method.


Solution:

Example 4: Find 2C016 – 1A616 by 16’s compliment method.


Solution:

Binary Representation of Integers


Computers use binary numbers for storing information. They use a fixed number of bits for
representation binary integers. Integers can be represented in 8-bit, 16-bit, 32-bit or 64-bit word
lengths. Integers are of two types: Unsigned Integers and Signed Integers
1. Unsigned Integers:
They include zero and positive integers. In the binary number system, an N-bit unsigned
integer can represent integers from 0 to 2N – 1. For N = 8 there are 28 distinct integers
from is 0 to 28 – 1 (= 255).
CN XI – SR Page 15
2. Signed Integers:
i) They include zero, positive integers and negative integers.
ii) They are represented in three forms:
a) Sign-Magnitude
b) 1’s Compliment
c) 2’s Compliment
iii) In representing signed integers, the leftmost bit is the most significant bit (MSB) or
the sign bit.
Sign-Magnitude Representation:
In this representation,
i) The MSB or the nth bit is the sign bit. It holds the value 0 for positive integer and
1 for a negative integer.
ii) The remaining (n – 1) bits represent the magnitude (or absolute value) of the
integer.
iii) Total numbers represented by an N-bit word using sign-magnitude representation
are 2N – 1.
iv) In general for a word size of N bits, the maximum positive number that can be
represented using sign magnitude form is + (2N – 1 – 1) and the maximum negative
number that can be represented using sign magnitude form is – (2N – 1 – 1).
Example 1: Represent +15 in sign magnitude form given a word size of 8-bits.
Solution:

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.

Example: Express -25 in 8-bit 1’s compliment form.


Solution:

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)

2’s Compliment Representation:


In this representation,
i) Every positive integer is represented in its true form, by its binary equivalent. For
e.g. +14 is represented as 1110.
ii) Every negative integer is represented by its 2’s compliment binary form.
iii) Total numbers represented by an N–bit word using 2’s compliment representation
are 2N.
iv) Computers use 2’s compliment for representing signed integers.
v) There is only one representation for the number 0 in 2’s compliment as zero is
considered as always positive (sign bit is 0) in 2’s complement representation.

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:

Encoding Real Numbers:


Real numbers are numbers with fractions. There are two representations to store real numbers:
i) Fixed point
ii) Floating point

1. Fixed Pont Representation:


i) It consists of a fixed number of bits before or after the radix point.
ii) There are 3 parts of a fixed point representation:
a) Sign bit (optional) – 1 for positive number, 0 for negative number
b) Integer – whole part to the left of the radix point.
c) Fraction – non-integer part to the right of the radix point.

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

iv) To represent a real number in fixed point notation:


a) Convert the number to binary form
b) Represent the binary number in fixed point notation. If number of bits is less than
n-bits then 0’s are added to the left (the leading zeros).

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

3. Normalized Scientific Notation:


i) Computers use normalized scientific form to represent binary floating point
numbers.
ii) A floating-point binary number is said to be in normalized scientific form if the most
significant digit of the mantissa is 1. For example 1.001 x 22, 1.00101 x 24

Example 1: Write 101.1001 x 23 in normalized form.


Solution:
101.1001 x 23 = 101.1001 x 23 x 22
= 1.011001 x 25 (normalized form)

Example 2: Represent (10110.11)2 in normalized mantissa-exponent form.


Solution:

CN XI – SR Page 19
(10110.11)2 = 10110.11 x 20 = 10110.11 x 20 x 24
= 1.011011 x 24 (normalized form)

Example 3: Express 0.000000001101 x 23 in normalized scientific form.


Solution:
0.000000001101 x 23 = 0.000000001101 x 23 x 2–9
= 1.101 x 2-6 (normalized form)

Encoding Characters:
Characters are encoded by a special group of symbols called ‘CODES’. The various types of
codes are:

S No. Code Example


1 Non – Binary Morse code
2 Binary Gray code, BCD, Excess – 3 code,
3 Alphanumeric ASCII code, EBCDIC, ISCII, Unicode

S No. Code Name Size Description


(in
bits)
1 Morse code - Alphabet is represented by a series of dots and dashes
4 Each digit of a decimal number is represented by binary
2 BCD or 8–4–2–1
equivalent
4 It can be derived from BCD code by adding 3 to each
3 Excess – 3
coded number
4 ASCII 7 It represents 128 alphanumeric codes
5 EBCDIC 8 It represents 256 alphanumeric codes
6 Unicode 16 It represents 65536 characters and symbols

Example 1: Write the BCD code for (943)10.


Solution:
(943)10 = 9 4 3

8421 8421 8421


1001 0100 0011
= (100101000011)2

Example 2: What is the message encoded in following ASCII code?


1001000 1000101 1001100 1010000
Solution:
CN XI – SR Page 20
64 32 16 8 4 2 1
1 0 0 1 0 0 0 = 72 = H
1 0 0 0 1 0 1 = 69 = E
= HELP
1 0 0 1 1 0 0 = 76 = L
1 0 1 0 0 0 0 = 80 = P

CN XI – SR Page 21

You might also like