0% found this document useful (0 votes)
13 views59 pages

Unit 1 Data Representation

Uploaded by

dekud9556
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)
13 views59 pages

Unit 1 Data Representation

Uploaded by

dekud9556
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/ 59

https://genuinenotes.

com

CHAPTER 1:

DATA REPRESENTATION
Nipun Thapa
https://genuinenotes.com Nipun Thapa / Computer Organization 2

Data Representation
Data :
• It refers to the symbols that represent people, events,
things, and ideas. Data can be a name, a number, the
colors in a photograph, or the notes in a musical
composition.
• The term “data” refers to factual information used for
analysis or reasoning.
https://genuinenotes.com Nipun Thapa / Computer Organization 3

Data Representation..
Data Representation
• It refers to the form in which data is stored, processed,
and transmitted.
• Devices such as smartphones, iPods, and computers
store data in digital formats that can be handled by
electronic circuitry (motherboard).
• Digitization is the process of converting information, such
as text, numbers, photo, or music, into digital data that
can be manipulated by electronic devices.
• The Digital Revolution has evolved through four phases,
beginning with big, expensive, standalone computers, and
progressing to today’s digital world in which small,
inexpensive digital devices are everywhere.
https://genuinenotes.com Nipun Thapa / Computer Organization 4

Data Types
The data types found in the registers of digital
computers may be classified as being one of the following
categories:

1. Numbers used in arithmetic computation,


2. Letters of the alphabet used in data processing,
3. Other discrete symbols used for specific purposes.

Data are numbers and other binary-coded information that are


operated on to achieve required computational results.
https://genuinenotes.com Nipun Thapa / Computer Organization 5

Data Representation
• The 0s and 1s used to represent digital data are referred
to as binary digits — from this term we get the word bit
that stands for binary digit.
• A bit is a 0 or 1 used in the digital representation of data.
• In digital computers, the user input is first converted and
transmitted as electrical pulses that can be represented
by two unique states ON and OFF.
• The ON state may be represented by a “1” and the off
state by a “0”.The sequence of ON’S and OFF’S forms
the electrical signals that the computer can understand.
https://genuinenotes.com Nipun Thapa / Computer Organization 6

Data Representation
https://genuinenotes.com Nipun Thapa / Computer Organization 7

Representing Numbers
• Numeric data consists of numbers that can be used in
arithmetic operations.
• Digital devices represent numeric data using the binary
number system, also called base 2.
https://genuinenotes.com Nipun Thapa / Computer Organization 8

Number System
Decimal
• Base, or radix (r) = 10
• 10 symbols: 0,1,2,3,4,5,6,7,8,9
• E.g. 630.5 = 6*102 + 3*101 + 0*100 + 5*10-1
https://genuinenotes.com Nipun Thapa / Computer Organization 9

Decimal
https://genuinenotes.com Nipun Thapa / Computer Organization 10

Decimal
https://genuinenotes.com Nipun Thapa / Computer Organization 11

Decimal
https://genuinenotes.com Nipun Thapa / Computer Organization 12

Decimal
https://genuinenotes.com Nipun Thapa / Computer Organization 13

Number System
Binary
• r=2
• 2 symbols: 0,1
• E.g. 110010.01 = 1*25 + 1*24 + 0*23 + 0*22 + 1*21 + 0*20 + 0*2-1 + 1*2-2

-The binary number system only has two digits: 0 and 1.


-No numeral like 2 exists in the system, so the number
“two” is represented in binary as 10 (pronounced “one
zero”).
https://genuinenotes.com Nipun Thapa / Computer Organization 14

Binary
https://genuinenotes.com Nipun Thapa / Computer Organization 15

Number System
Octal
• r=8
• 8 symbols: 0,1,2,3,4,5,6,7

• E.g. (736.4)8 = 7*82 + 3*81 + 6*80 + 4*8-1


https://genuinenotes.com Nipun Thapa / Computer Organization 16

Octal
https://genuinenotes.com Nipun Thapa / Computer Organization 17

Number System
• Hexadecimal
• r = 16
• 16 symbols: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
• E.g. A9D = A*162 + 9*161 + D*160

The hexadecimal numeral system, often shortened


to "hex", is a numeral system made up of 16 symbols (base
16).
The standard numeral system is called decimal
(base 10) and uses ten symbols: 0,1,2,3,4,5,6,7,8,9.
Hexadecimal uses the decimal numbers and six
extra symbols.
https://genuinenotes.com Nipun Thapa / Computer Organization 18

Conversion
I. Base r to decimal
• Multiply each coefficient with corresponding power of r and add.
II. Decimal to base r
• Divide by base r and collect remainder upwards.
• Converting decimal fraction to binary, multiplication is used instead
of division.
• And, integers are calculated instead of remainders.
• Those remainders are collected downwards.
• E.g. (0.625)10 = (?)2

Integer Fraction Coefficient


0.625*2 1 0.25 1
0.25*2 0 0.5 0
0.5*2 1 0 1
https://genuinenotes.com Nipun Thapa / Computer Organization 19

Conversion
II. Decimal to base r
• Therefore, (0.625)10 = (0.101)2
• H/W, (65.553)10 = (?)2

III. Binary to octal (hexadecimal) & vice versa


• Conversion from binary to octal (hexadecimal) is accomplished by
partitioning the binary number into group of 3 (for octal) or 4 (for
hexadecimal) digits each starting from binary point (.) & proceeding to the
left and to the right.
• E.g. (1 101 001 . 111)2 = (151.7)8 (0110 1001 . 1101 0)2 = (69.D)16
• Converting from octal (hexadecimal) to binary is done by process in
reverse above.
• E.g. (673.124)8 = (110 111 011 . 001 010 100)2
(306.D)16 = (11 0000 0110 . 1101)2
https://genuinenotes.com Nipun Thapa / Computer Organization 20

Conversion
1. Binary to decimal
e.g. 1110012 = 1x25+1x24+1x23+0x22+0x21+1x20 = 5710
2.Octal to Decimal
e.g. 378 = 3×81+7×80 = 24+7 = 3110
3.Hexadecimal to Decimal
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
E.g. C916 :
9 = 9 * (16 ^ 0) = 9
C = 12 * (16 ^ 1) = 192
then, we add the results : 192 + 9 = 20110
https://genuinenotes.com Nipun Thapa / Computer Organization 21

Conversion
3.Hexadecimal to Decimal
e.g. (ABC)16 :
C = 12 * (16 ^ 0) =12
B = 11 * (16 ^ 1) =176
A = 10 * (16 ^ 2) = 2560
Then, we add the results.
2560 + 176 + 12 = 274810 decimal
Test Yourself!
• Convert Hex AF, ACD, AB2 and FF to base 10
• Answers are 17510, 276510, 273810, and 25510 respectively.
https://genuinenotes.com Nipun Thapa / Computer Organization 22

Conversion
4.Decimal to Binary
Convert 1310 to binary

Division
Quotient Remainder Bit #
by 2
13/2 6 1 0
6/2 3 0 1
3/2 1 1 2
1/2 0 1 3

So 1310 = 11012

So 17410 = 101011102
https://genuinenotes.com Nipun Thapa / Computer Organization 23

Conversion
5.Decimal to octal
Example: convert (177)10 to octal
177 / 8 = 22 remainder is 1
22 / 8 = 2 remainder is 6
2 / 8 = 0 remainder is 2
Answer = (261)8
6. Decimal to Hexadecimal
Example: convert (4768)10 to hex.
= 4768 / 16 = 298 remainder 0
= 298 / 16 = 18 remainder 10 (A)
= 18 / 16 = 1 remainder 2
= 1 / 16 = 0 remainder 1
Answer: 1 2 A 0
https://genuinenotes.com Nipun Thapa / Computer Organization 24

Conversion
7.Binary to octal and Hex
Example − Convert binary number 10010110 into octal
number.
First convert this into decimal number
= (10010110)2
= 1x27+0x26+0x25+1x24+0x23+1x22+1x21+0x20
= 128+0+0+16+0+4+2+0 = (150)10
Then, convert it into octal number
= (150)10 = 2x82+2x81+6x80
= (226)8 which is answer.
https://genuinenotes.com Nipun Thapa / Computer Organization 25

Conversion
7.Binary to octal and Hex
Using Grouping

Octal Digit Value Binary Equivalent


0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
https://genuinenotes.com Nipun Thapa / Computer Organization 26

Conversion
7.Binary to octal
• So, if you make each group of 3 bit of binary input number, then
replace each group of binary number from its equivalent octal digits.
That will be octal number of given number . Note that you can add
any number of 0’s in leftmost bit (or in most significant bit) for integer
part and add any number of 0’s in rightmost bit (or in least significant
bit) for fraction part for completing the group of 3 bit, this does not
change value of input binary number.
• So, these are following steps to convert a binary number into octal
number.
• Take binary number
• Divide the binary digits into groups of three (starting from right) for integer part
and start from left for fraction part.
• Convert each group of three binary digits to one octal digit.
This is simple algorithm where you have to grouped binary
number and replace their equivalent octal digit.
https://genuinenotes.com Nipun Thapa / Computer Organization 27

Conversion
7.Binary to octal
Example-1 − Convert binary number 1010111100 into octal
number. Since there is no binary point here and no
fractional part. So,
https://genuinenotes.com Nipun Thapa / Computer Organization 28

Conversion
7.Binary to octal
Therefore, Binary to octal is.
= (1010111100)2
= (001 010 111 100)2
= (1 2 7 4)8
= (1274)8
https://genuinenotes.com Nipun Thapa / Computer Organization 29

Conversion
7.Binary to octal
Example-2 Convert binary number 0110 011.1011 into
octal number. Since there is binary point here and fractional
part. So,
https://genuinenotes.com Nipun Thapa / Computer Organization 30

Conversion
7.Binary to octal
Therefore, Binary to octal is.
= (0110 011.1011)2
= (0 110 011 . 101 1)2
= (110 011 . 101 100)2
= (6 3. 5 4)8
= (63.54)8
https://genuinenotes.com Nipun Thapa / Computer Organization 31

Conversion
8.Binary to Hexadecimal
These are following steps to convert a binary
number into hexadecimal number.
• Take binary number
• Divide the binary digits into groups of four (starting from
right) for integer part and start from left for fraction part.
• Convert each group of four binary digits to one
hexadecimal digit.
https://genuinenotes.com Nipun Thapa / Computer Organization 32

Conversion
8.Binary to Hexadecimal
Example-1 − Convert binary number 1010101101001 into
hexadecimal number. Since there is no binary point here
and no fractional part. So,
https://genuinenotes.com Nipun Thapa / Computer Organization 33

Conversion
8.Binary to Hexadecimal
Example − Convert binary number 1101010 into
hexadecimal number.
First convert this into decimal number:
= (1101010)2
= 1x26+1x25+0x24+1x23+0x22+1x21+0x20
= 64+32+0+8+0+2+0
= (106)10
Then, convert it into hexadecimal number
= (106)10
= 6x161+10x160
= (6A)16 which is answer.
https://genuinenotes.com Nipun Thapa / Computer Organization 34

Conversion
8.Binary to Hexadecimal

Hexa 0 1 2 3 4 5 6 7
Binary 0000 0001 0010 0011 0100 0101 0110 0111

Hexa 8 9 A=10 B=11 C=12 D=13 E=14 F=15


Binary 1000 1001 1010 1011 1100 1101 1110 1111
https://genuinenotes.com Nipun Thapa / Computer Organization 35

Conversion
8.Binary to Hexadecimal
Therefore, Binary to hexadecimal is,
= (1010101101001)2
= (1 0101 0110 1001)2
= (0001 0101 0110 1001)2
= (1 5 6 9)16
= (1569)16
https://genuinenotes.com Nipun Thapa / Computer Organization 36

Conversion
8.Binary to Hexadecimal
Example-2 − Convert binary number 001100101.110111
into hexadecimal number. Since there is binary point here
and fractional part. So,
https://genuinenotes.com Nipun Thapa / Computer Organization 37

Conversion
8.Binary to Hexadecimal
Therefore, Binary to hexadecimal is,
= (001100101.110111)2
= (0 0110 0101 . 1101 1100)2
= (0110 0101 . 1101 1100)2
= (6 5 . D C)16
= (65.DC)16
https://genuinenotes.com Nipun Thapa / Computer Organization 38

Complements
Complements are used in digital systems for
simplifying the subtraction operation and for logic
manipulation.
Two types of complements are:
• r’s complement
• (r-1)’s complement
https://genuinenotes.com Nipun Thapa / Computer Organization 39

Complements
Complements are used in digital systems for
simplifying the subtraction operation and for logic
manipulation.
Two types of complements are:
• r’s complement
• (r-1)’s complement
When the value of the base r is substituted in the
name, the two types are referred to as the 2’ and 1’s
complements for binary numbers and the 10’s and 9’s
complements for decimal numbers.
https://genuinenotes.com Nipun Thapa / Computer Organization 40

Complements
i) r’s complement
r’s complement of N (positive number with base r) is
defined as
rn – N, for N ≠ 0
and
0, for N=0
where,
n=number of digits (integer parts only)
• E.g. (147.53)10, c = 103 – 147.53 = 852.47 Ans.
https://genuinenotes.com Nipun Thapa / Computer Organization 41

Complements
ii) (r-1)’s complement
(r-1)’s complement of N (positive number with base
r) is defined as
(rn – r - m) – N, for number with fraction
(rn – 1) – N, for number with integer only
where,
n  number of digits in integer part of N
m  number of digits in fraction part of N
r  base or radix
E.g. (147.53)9, c = 103 – 10-2 - 147.53 = 852.46 Ans
https://genuinenotes.com Nipun Thapa / Computer Organization 42

Complements
• To find (r-1)’s complement, subtract all digit from (r-1).
E.g. for 1’s complement, subtract each digit from 1.
for 7’s complement, subtract each digit from 7.
for 9’s complement, subtract each digit from 9.
for 15’s complement, subtract each digit from 15.
And,
• To find r’s complement, subtract each digit from (r-1), and then add 1 to the last digit.
E.g. for 2’s complement, subtract each digit from 1, and then add 1 to the last digit.
for 8’s complement, subtract each digit from 7, and then add 1 to the last digit.
for 10’s complement, subtract each digit from 9, and then add 1 to the last digit
for 16’s complement, subtract each digit from 15, and then add 1 to the last digit.
• C/W, Give some examples on 1’s complement and 2’s complement.
https://genuinenotes.com Nipun Thapa / Computer Organization 43

Complements
For eg : 9’s complement of 54670 with n= 5 we have 106 = 1000000
and 106-1=999999 then,
999999-546700=453299 and the 9’s complement of 12389 is
9999-12389=87610
For binary number
r=2 and r-1 = 1, so the 1’s complement of N is (2n – 1) – N .
If , n = 4 , we have 24= (10000)2 – 1 = (1111)2

The (r-1)’s complement of octal or hex number are obtained by


subtracting each digit from 7 or F(decimal 15) respectively .
https://genuinenotes.com Nipun Thapa / Computer Organization 44

Complements
r ‘ s Complement of an n-digit
Note : the r’s complement is obtained by adding 1 to the (r-
1)’s complements ie:
Rn-N = [ ( rn-1 ) - N ] +1
i) Thus 10’s complement of decimal 2389 is
7610+1=7611
https://genuinenotes.com Nipun Thapa / Computer Organization 45

Subtracting of Unsigned Number


#Subtraction with r’s complement
• Subtraction of two positive numbers (M - N), both of base r, is
done as follows:
i) Add M to r’s complement of N.
ii) If an end carry occurs, discard it. What is left is result.
iii) If an end carry does not occur, take r’s complement of the number
obtained in step (i) and place a negative sign in front. That is the result.

#Subtraction with (r-1)’s complement


• Subtraction of two positive numbers (M - N), both of base r, is
done as follows:
i) Add M to (r-1)’s complement of N.
ii) If an end carry occurs, add 1 to LSB. What is received is result.
iii) If an end carry does not occur, take (r-1)’s complement of the number
obtained in step (i) and place a negative sign in front. That is the result.
https://genuinenotes.com Nipun Thapa / Computer Organization 46

Subtracting of Unsigned Number



https://genuinenotes.com Nipun Thapa / Computer Organization 47

Subtracting of Unsigned Number



https://genuinenotes.com Nipun Thapa / Computer Organization 48

Subtracting of Unsigned Number


Using the two binary numbers X=1010100 and Y=1000011, we perform
the subtraction X-Y and Y-X using 2’s complements :
X = 1010100
2’s complement of Y = +0111101
Sum = 10010001
Discard end carry 27 = -10000000
Answer : X-Y = 0010001

Y = +000011
2’s complement of X = +0101100
Sum = 1101111
There is no end carry
Answer is negative 0010001 = 2’s complement of 1101111
https://genuinenotes.com Nipun Thapa / Computer Organization 49

Fixed-Point Representation
• Because of hardware limitations, computers must
represent everything with 1's and 0's, including the sign of
a number.
• There will be problem in storing +ve/-ve sign (+/-) and
binary (or decimal) point.
• Convention is 0 for +ve sign and 1 for –ve sign.
https://genuinenotes.com Nipun Thapa / Computer Organization 50

Fixed-Point Representation
Integer Representation
Suppose, we have 8-bit register.
For +ve number,
i) Signed-magnitude representation
When an integer binary number is positive, the sign is represented by 0 and the magnitude by a
positive binary number.
E.g. +14 = 0 0001110

For –ve number,


i) Signed-magnitude representation
1 for the -ve sign followed by binary equivalent of that number. E.g. -14 = 1 0001110
ii) Signed-1’s complement representation
1 for the -ve sign followed by 1’s complement of that number. E.g. -14 = 1 1110001
iii) Signed-2’s complement representation
1 for the -ve sign followed by 2’s complement of that number. E.g. -14 = 1 1110010
https://genuinenotes.com Nipun Thapa / Computer Organization 51

Fixed-Point Representation
• Signed-magnitude system is used in ordinary arithmetic
while the signed-complement is used in computer
arithmetic.
• The 1’s complement has two representations of 0 (+0 and
-0), hence brings difficulties and used in some older
computers.
• The 2’s complement is widely used.
https://genuinenotes.com Nipun Thapa / Computer Organization 52

Fixed-Point Representation
Arithmetic Addition
Note: negative number must initially be in 2’s complement
and that if the sum obtained after the addition is negative, it
is in 2’s complement form.
e.g.

+6 : 0 0000110 - 6 : 1 1111010
+13 : 0 0001101 +13 : 0 0001101
+19 : 0 0010011 +7 : 0 0010011

+6 : 0 0000110 -6 : 1 1111010
- 13 : 1 1110011 -13 : 1 1110011
- 7 : 1 1111001 -19 : 1 1101101
https://genuinenotes.com Nipun Thapa / Computer Organization 53

Fixed-Point Representation
Overflow
• When two numbers of n digits each are added and the sum occupies
n + 1 digits, we say that an overflow occurred.
• An overflow is a problem in digital computers because the width of
registers is finite.
• A result that contains n + 1 bits cannot be accommodated in a register
with a standard length of n bits.
• For this reason, many computers detect the occurrence of an
overflow, and when it occurs, a corresponding flip-flop is set which
can then be checked by the user.
• The detection of an overflow after the addition of two binary numbers
depends on whether the numbers are considered to be signed or
unsigned.
https://genuinenotes.com Nipun Thapa / Computer Organization 54

Fixed-Point Representation
Overflow
• When two unsigned numbers are added, an overflow is detected from
the end carry out of the most significant position.
• In the case of signed numbers, the leftmost bit always represents the
sign, and negative numbers are in 2's complement form. When two
signed numbers are added, the sign bit is treated as part of the
number and the end carry does not indicate an overflow.
• An overflow cannot occur after an addition if one number is positive
and the other is negative, since adding a positive number to a
negative number produces a result that is smaller than the larger of
the two original numbers.
https://genuinenotes.com Nipun Thapa / Computer Organization 55

Fixed-Point Representation
Overflow
• An overflow may occur if the two numbers added are both either
positive or both negative.
• E.g.

• An overflow condition can be detected by observing that if these two


carries are not equal, an overflow condition is produced.
• If the two carries are applied to an exclusive OR (XOR) gate, an
overflow will be detected when the output of the gate is equal to 1.
https://genuinenotes.com Nipun Thapa / Computer Organization 56

Floating-Point Representation
Floating-Point Representation has two parts:
i) Mantissa (a signed number, may be a fraction or an
integer)
ii) Exponent
E.g. +62345.54 = +(0.6234554)*10+5

Fraction Exponent
+0.6234554 +5
https://genuinenotes.com Nipun Thapa / Computer Organization 57

Floating-Point Representation
• General form,
• m * re, where r = radix
• A floating point binary number is represented in a similar
manner except that it uses base 2 for the exponent. For
example, the binary number +1001.11 is represented with an 8-
bit fraction and 6-bit exponent as follows:
• m * 2e = +(.100111)2 * 2+4

Fraction Exponent
01001110 000100

• The fraction has a 0 in the leftmost position to denote positive.


• The binary point of the fraction follows the sign bit but is not
shown in the register.
• A floating point number is said to be normalized if the most
significant digit of the mantissa is nonzero.
https://genuinenotes.com Nipun Thapa / Computer Organization 58

Floating-Point Representation
Two main standard forms of the floating point number by
• ANSI (American National Standards Institute)
• IEEE (Institute of Electrical and Electronic Engineers)
The ANSI 32-bit floating-point number in byte format is:

where,
S = sign of Mantissa
E = exponent bits (in 2’s complement)
M = mantissa bits
E.g.
13 = 1101 = +(.1101) * 24 = 00000100 11010000 00000000 00000000
-17 = -10001 = -(.10001) * 25 = 10000101 10001000 00000000 00000000
-0.12510 = -0.0012 = -(.1) * 2-2 = 11111110 10000000 00000000 00000000
https://genuinenotes.com Nipun Thapa / Computer Organization 59

Thank You
Chapter 1 is finished !!!

You might also like