10.4 Floating- Point Representation
COS2621 - Computer Organisation · 10. Computer Arithmetic
Floating-Point Representation
Floating-point representation is a method used to encode real numbers within a computer. This method allows for a wide range of values by using a scientific notation format. The format consists of three parts: the sign, the exponent, and the mantissa (also known as the significand).
Components of Floating-Point Representation
The floating-point format can be defined as follows:
- Sign bit: This indicates whether the number is positive (0) or negative (1).
- Exponent: This represents the power of two by which the mantissa is multiplied. It is usually stored in a biased form to allow for both positive and negative exponents.
- Mantissa: This is the significant part of the number, representing the precision bits.
For example, the number -6.25 can be represented in floating-point format. The binary representation of 6.25 is 110.01 in binary. In floating-point representation, this can be expressed as:
-1.1001 × 2^2
Here, the sign bit is 1 (indicating a negative number), the exponent is 2, and the mantissa is 1.1001.
IEEE 754 Standard
The IEEE 754 standard defines the representation of floating-point numbers. There are two main formats: single precision and double precision.
- Single precision: This uses 32 bits, with 1 bit for the sign, 8 bits for the exponent, and 23 bits for the mantissa.
- Double precision: This uses 64 bits, with 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa.
To represent the decimal number 30.5 in single precision:
- Convert to binary: 30.5 = 11110.1
- Normalise the binary: 1.11101 × 2^4
- Sign bit: 0 (positive number)
- Exponent: 4 + 127 (bias) = 131 (in binary: 10000011)
- Mantissa: 11101000000000000000000 (23 bits)
The final representation in IEEE 754 single precision is:
0 10000011 11101000000000000000000
Advantages and Limitations of Floating-Point Representation
Advantages:
- It can represent very large and very small numbers.
- It provides a way to perform arithmetic on real numbers efficiently.
Limitations:
- Precision errors can occur due to rounding.
- Not all decimal fractions can be represented exactly.
Watch out: Be careful with precision errors when performing arithmetic with floating-point numbers. Always consider the potential for rounding errors.
Summary
Floating-point representation allows for the encoding of real numbers using sign, exponent, and mantissa. The IEEE 754 standard defines how floating-point numbers are represented in computers.
Check your understanding
- What are the three components of a floating-point number?
- How does the IEEE 754 standard differ between single and double precision?
- What are some limitations of using floating-point representation?
Test yourself
5 quick questions on this lesson. Pick an answer to see if you're right.
1. instructions provide computational capabilities for processing numeric data.
2. What is the main purpose of the sign bit in floating-point representation?
3. In IEEE 754 single precision format, how many bits are allocated for the exponent?
4. What is a limitation of floating-point representation?
5. Which of the following is true about the mantissa in floating-point representation?