0% found this document useful (0 votes)
11 views

Unit 1 Part C

The document discusses data representation in computer systems, focusing on methods for storing and manipulating numbers, characters, and instructions. It outlines three primary representations: Signed Number Representation (including Sign-Magnitude, One's Complement, and Two's Complement), Fixed-Point Representation, and Floating-Point Representation. Each method has its own advantages and drawbacks, particularly in terms of how negative numbers are represented and the efficiency of storage.

Uploaded by

nsohailkhan39
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Unit 1 Part C

The document discusses data representation in computer systems, focusing on methods for storing and manipulating numbers, characters, and instructions. It outlines three primary representations: Signed Number Representation (including Sign-Magnitude, One's Complement, and Two's Complement), Fixed-Point Representation, and Floating-Point Representation. Each method has its own advantages and drawbacks, particularly in terms of how negative numbers are represented and the efficiency of storage.

Uploaded by

nsohailkhan39
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Data

Representation
and Computer
Arithmetic
By Dr. Charu Goyal
Data Representation
 Method of storing and manipulating data in
computer system.
 This includes numbers, characters, and
instructions.
 There are 3 ways of representing the data:
 Signed Number Representation
 Fixed-Point Representation
 Floating-Point Representation
Signed Number
Representation
Signed Number Representation
Signed numbers can be represented in three primary ways:

1.Sign-Magnitude Representation: The leftmost bit (MSB) is the sign bit (0 for
positive, 1 for negative), while the remaining bits represent the magnitude.
•Example: 5 → 00000101, -5 → 10000101
•The range of signed integer representation of an n-bit number is given as –
(2^{n-1}-1) to (2)^{n-1}-1.

 Let n = 4
 Range:
–(2^{4-1}-1) to 2^{4-1}-1
= -(2^{3}-1) to 2^{3}-1
= -(7) to+7
 For 4 bit representation, minimum value=-7 and maximum value=+7
Drawbacks:
 1. For 0, there are two representations: -0 and +0 which should not
be the case as 0 is neither –ve nor +ve.
2. Out of 2^n bits for representation, we are able to utilize
only 2^{n-1} bits.
3. Numbers are not in cyclic order i.e. After the largest number (in
this, for example, +7) the next number is not the least number (in
this, for example, +0).
4. For negative numbers signed extension does not work.
 5. For +ve representation, if 4 bits are extended to 5 bits there is a
need to just append 0 in MSB.
6. But if the same is done in –ve representation we won’t get the
same number. i.e. 10101 ≠ 11101.
Signed Number
Representation
2.One’s Complement Representation: Negative numbers are obtained by inverting all bits
of the positive number.
•Example: 5 → 00000101, -5 → 11111010
 For –ve numbers, we can follow any one of the two approaches:

 Write the +ve number in binary and take 1’s complement of it.

 1’s complement of 0 = 1 and 1’s complement of 1 = 0


 Example:
(-5) in 1’s complement:
+5 = 0101
-5 = 1010

 Write Unsigned representation of 2^n-1-X for –X.


 Example: –X = -5 for n=4 2^4-1-5=10 ->1010(Unsigned)

 The range of 1’s complement integer representation of n-bit number is given


as –(2^{n-1}-1) to 2^{n-1}-1.
Signed Number
Representation
 Drawbacks:

1. For 0, there are two representations: -0 and +0 which should not be the case as
0 is neither –ve nor +ve.

2. Out of 2^n bits for representation, we are able to utilize only 2^{n-1} bits.

 Merits over Signed bit representation:


 1. Numbers are in cyclic order i.e. after the largest number (in this, for
example, +7) the next number is the least number (in this, for example, -7).
2. For negative number signed extension works.
 For +ve as well as -ve representation, if 4 bits are extended to 5 bits there is a
need to just append 0/1 respectively in MSB.
Signed Number
Representation
3.Two’s Complement Representation: Negative numbers are obtained by inverting all bits of the
number and adding 1 to the least significant bit (LSB).
•Example: 5 → 00000101, -5 → 11111011
 1. For +ve numbers, the representation rules are the same as signed integer representation.
2. For –ve numbers, there are two different ways we can represent the number.

 Write an unsigned representation of 2^n-X for –X in n-bit representation.

 Example:
(-5) in 4-bit representation
2^4-5=11 -→1011(unsigned)

 Write a representation of +X and take 2’s Complement.


 To take 2’s complement simply take 1’s complement and add 1 to it.

 Example:
(-5) in 2’s complement
(+5) = 0101
1’s complement of (+5) = 1010
Add 1 in 1010: 1010+1 = 1011
Therefore (-5) = 1011

 Range of representation of n-bit is –(2^{n-1} ) to (2)^{(n-1)-1}.


 Merits:

1. No ambiguity in the representation of 0.

2. Numbers are in cyclic order i.e. after +7 comes -8.

3. Signed Extension works.

4. The range of numbers that can be represented using 2’s


complement is very high.
Fixed-Point Representation

•Fixed-point numbers are used to represent real


numbers where the decimal (or binary) point is fixed
in a specific location.

•Example: 1101.101 in binary (fixed 3 places after


decimal) represents 13.625 in decimal.
Floating-Point
Representation
•Used to represent very large or small numbers efficiently.
•Format: Sign | Exponent | Mantissa
•IEEE 754 Single Precision (32-bit):
•Sign (1 bit): 0 for positive, 1 for negative
•Exponent (8 bits): Stores the exponent with a bias (127 for
single precision)
•Mantissa (23 bits): Stores the fractional part of the number
•Example:
•Decimal 10.5 in IEEE 754 format:
•Binary: 1010.1
•Normalized: 1.0101 × 2^3
•IEEE 754: 01000001001010000000000000000000

You might also like