Module II Data Representation and Arithmetic Algorithms Number
Module II Data Representation and Arithmetic Algorithms
Number Representation • Based on the number system, two basic datatypes are implemented in computer system: § Fixed Point Numbers § Floating Point Numbers
Fixed Point Representation • Fixed Point Numbers (Integers) are represented in two forms: § Unsigned Integer § Signed Integer
Unsigned Integer • It is fixed point system with no fractional digits. • Does not have provision for negative numbers • E. g. A 4 -bit unsigned integer has values ranging from 0000(010) to 1111(1510)
Signed Numbers • It has provision to represent signed numbers. • It can be represented in 3 ways: – Sign Magnitude Representation – 1’s Complement – 2’s Complement
Sign Magnitude Representation • Most significant bit (MSB) is used to represent sign of number. • Example : 8 -bit representation • MSB = 0 positive number • MSB = 1 negative number
Sign Magnitude Representation • Examples: • Maximum positive number is 0111 1111(+127) • Maximum negative number is 1111(-127) • Drawback: – Zero has two representation (1000 0000 and 0000) which makes it difficult to test for zero operations
1’s Complement Representation • Obtained by complementing each bit of corresponding +ve number • It is equivalent to subtracting that number from 2 n -1 • E. g. 0010 1101
2’s Complement Representation • It is obtained by subtracting corresponding number from 2 n • It is obtained by adding 1 to 1’s complement • E. g. 0010 1110 • Advantages: – It has only +0 representation – It is efficient for logic circuit implementation and hence is used for addition and subtraction operation
Floating Point Representation • Binary point varies and hence representation is required • FP Representation has 3 fields: – Significant digits (Mantissa) – Exponent
Floating Point Representation • Example: • Here, – Sign = 0 – Mantissa = 1110110 – Exponent is 5 (Bias value is added to represent negative exponent)
IEEE 754 Standard • Two standards: – Single Precision Representation – Double Precision Representation
Single Precision Representation • 32 -bit representation • Divided into 3 fields : – Sign : 1 -bit – Exponent : 8 -bit – Mantissa : 23 -bits • Instead of signed exponent, the value stored in exponent field is E = E + bias • Bias for 32 -bit is 127, it is called excess-127 format
Double Precision Representation • 64 -bit representation • Divided into 3 fields : – Sign : 1 -bit – Exponent : 11 -bit – Mantissa : 52 -bits • Exponent field is E = E + bias • Bias for 64 -bit is 1023, it is called excess-1023 format
Problem 1 • Represent 1259. 125 in single precision and double precision format
Problem 2 • Represent -307. 1875 in single precision and double precision format
Problem 3 • Represent 0. 0625 in single precision and double precision format
Integer Addition and Subtraction
Integer Addition and Subtraction
Integer Addition and Subtraction
- Slides: 20