Computer Organization and Architecture: Chapter 2: Arithmetic for Computers

Floating Point Numbers and their Representation

Arithmetic for Computers

Questions: 1. Define IEEE floating point single and double precision standard. 2. What is denormal? Define NaN ? 3. In conforming to the IEEE standard mention any four situations under which a processor sets exception flag. 4. Define underflow and overflow.

Floating Point Numbers and their Representation

• The standards for representing floating point numbers in 32‒bits and 64‒bits have been developed by the Institute of Electrical and Electronics Engineers (IEEE), referred to as IEEE 754 standards. Fig. 2.6.1 shows these IEEE standard formats.

• The 32‒bit standard representation shown in Fig. 2.6.1 (a) is called single‒precision representation because it occupies a single 32‒bit word. The 32‒bits are divided into three fields as shown below:

(field 1) Sign   ← 1‒bit

(field 2) Exponent ← 8‒bits

(field 3) Mantissa ← 23‒bits

• Instead of the signed exponent, E, the value actually stored in the exponent field is E' = E (scaling factor) + bias.


• In the 32‒bit floating point system (single precision), bias is 127. Hence E'= E (scaling factor) + 127. This representation of exponent is also called as the excess‒127 format.

• The end values of E', namely, 0 and 255, are used to indicate the floating point values of exact zero and infinity, respectively in single precision.

• Thus range of E' for normal values in single precision is 0 < E' < 255. This means that for 32‒bit representation the actual exponent E is in the range ‒ 126 ≤ E ≤ 127.

• The 64‒bit standard representation shown in Fig. 2.6.1 (b) is called a double‒precision representation because it occupies two 32‒bit words.

• The 64‒bits are divided into three fields as shown below:

(field 1) Sign   ← 1 ‒ bit

(field 2) Exponent ← 11 ‒ bit

(field 3) Mantissa ←52 ‒ bits

• In the double precision format value actually stored in the exponent field is given as

E' = E + 1023

• Here, bias value is 1023 and hence it is also called excess‒1023 format.

• The end values of E', namely, 0 and 2047, are used to indicate the floating point exact values of exact zero and infinity, respectively.

• Thus the range of E' for normal values in double precision is 0 < E' < 2047. This means that for 64‒bit representation the actual exponent E is in the range

‒ 1022 ≤ E ≤ 1023.

Example: 1

Represent 1259.12510 in single precision and double precision formats.

Solution:

Step 1: Convert decimal number in binary format


(1259)10 = (100 1110 1011)2

(0.125)10 = (0.001)2

Binary number = 10011101011+ 0.0 0 1= 1 0 0 1 1 1 0 1 0 1 1 . 0 0 1

Step 2: Normalize the number

1. 0 0 1 1 1 0 1 0 1 1. 0 0 1

1. 0 0 1 1 1 0 1 0 1 10 0 1 1 × 210

Step 3: Single precision representation

For a given number S = 0, E = 10 and M = 0 0 1 1 1 0 1 0 1 1 0 0 1

Bias for single precision format is = 127

E' = E + 127 = 10 + 127 = 13710

  = 1000 10012

Number in single precision format is given as


Step 4: Double precision representation

For a given number

S = 0, E = 10, and M = 0 0 1 1 1 0 1 0 1 1 0 0 1

Bias for double precision format is = 1023

E' = E+ 1023 = 10 + 1023 = 103310 = 1 0 0 0 0 0 0 1 0 0 12

Number in double precision format is given as


Example: 2

Represent ‒ 307.187510 in single precision and double precision formats.

Solution:

Step 1: Convert decimal number in binary format integer part


Integer part:

(307)10 = (133)16

(307)10 = (100110011)2

Fractional part :

(0.1875) 10 = (0.0011)2

Binary number = ‒ 100110011 + .0011

= ‒ 100110011. 0011

Step 2: Normalize the number

 ‒100 11001 1.00 11 = ‒ 1.0 0 1 1 0 0 1 1 0 0 1 1 ×28

Step 3: Single precision representation

For a given number

S = 1, E = 8, and M = 0011 0011 0011

Bias for single precision format is = 127

 E' = E + 127 = 8 + 127 = 13510 = 100001112

Number in single precision format is given as


Step 4: Double precision representation

For a given number

S = 1, E = 8 and M = 0011 0011 0011

Bias for double precision format is = 1023

E' = E + 1023 = 8 + 1023 = 103110 = 100000001112

Number in double precision format is given as


Example: 3

Show the IEEE 754 binary representation of the number (‒0.75)10 in single precision.

Solution:

Step 1: Convert decimal number in binary format.


‒ (0.75)10 = ‒ (0.11)2

Step 2: Normalize the number.

‒ 0.11 = ‒1.1×2‒1

Step 3: Single precision representation

For a given number S = 1, E = ‒1 and M = 1

Bias for single precision format is = 127

E' = E + 127 = (− 1) + 127 12610 = (01111110)2

Number in single precision format is given as,


Examples for Practice

Example: 4

Represent (309.1875)10 in single precision and double precision format.

Answer:


Example: 5

Represent (0.0625)10 Represent (0.0625)10 in single precision and double precision formats.

Answer:


Example: 6

Represent 32.75 and 18.125 in single precision IEEE 754 representation.

Answer:


 

1. Special Values

• The extreme values of biased exponent, E' are used to represent special values. When E' = 0 and the mantissa fraction M is zero, the value exact 0 is represented. The biased exponent with all 1s is reversed to represent infinity, where infinity is the result of dividing a normal number by zero. The sign bit is still part of these representations, so there are ±0 and ±∞ representations.

• When E' = 0 and M ≠ 0, denormal numbers are represented. A denormal is a result that causes an underflow and has leading 0s in the mantissa even after the exponent is adjusted to its smallest possible value. The E' with all 1s and M ≠ 0 is reserved to represent Not a Number (NaN). A NaN is the result of performing an invalid operation such as 0/0 or √‒1.


2. Exceptions

• According to IEEE standards, the processor sets exception flags if underflow, overflow, divide by zero, inexact or invalid conditions occur during the program execution.

Underflow: In a single precision, if the number requires an exponent less than ‒126 or in a double precision, if the number requires an exponent less than ‒1022 to represent its normalized form the underflow occurs.

Overflow : In a single precision, if the number requires an exponent greater than + 127 or in a double precision, if the number requires an exponent greater than + 1023 to represent its normalized form the overflow occurs.

Divide by zero: Divide by zero exception occurs when any number is divided by zero.

Inexact: Inexact is the name for a result that requires rounding in order to be represented in one of the normal formats.

Invalid : An invalid exception occurs if operations such as 0/0 or √1 are attempted. When exception occurs, the results are set to special values. System and user defined routines are used to handle such exceptions.

 

Review Questions

1. Define IEEE floating point single and double precision standard.

2. What is denormal? Define NaN ?

3. In conforming to the IEEE standard mention any four situations under which a processor sets exception flag.

4. Define underflow and overflow.

 

Computer Organization and Architecture: Chapter 2: Arithmetic for Computers : Tag: Computer : Arithmetic for Computers - Floating Point Numbers and their Representation


Computer Organization and Architecture: Chapter 2: Arithmetic for Computers



Under Subject


Computer Organization and Architecture

CW25201 3rd Semester IT department. | 2025 Regulation | 3rd Semester 2025 Regulation



Related Subjects


Discrete Mathematics

MA25C14 3rd Semester CSE,IT,CY,AIDS departments. | 2025 Regulation | 3rd Semester 2025 Regulation


Data Structures

CS25C08 3rd Semester CSE,IT,CY,AIDS departments. | 2025 Regulation | 3rd Semester 2025 Regulation


Computer Organization and Architecture

CW25201 3rd Semester IT department. | 2025 Regulation | 3rd Semester 2025 Regulation


Object Oriented Programming

CS25C07 3rd Semester IT department. | 2025 Regulation | 3rd Semester 2025 Regulation


Web Technologies

IT25301 3rd Semester IT department. | 2025 Regulation | 3rd Semester 2025 Regulation


English Communication Skills Laboratory I

EN25C03 3rd Semester all department. | 2025 Regulation | 3rd Semester 2025 Regulation


Skill Development Course I

3rd Semester all department. | 2025 Regulation | 3rd Semester 2025 Regulation