Arithmetic with IEEE-754 format
Addition
To add two floating-point numbers:
- Adjust position of binary points so significands have the same exponent.
- If numbers have the same sign, add significands. Otherwise subtract smaller from larger.
- If required, normalise significand at the end.
- Select correct sign depending on values.
Subtraction
Use the relationship .
Multiplication
To multiply two floating-point numbers:
- Add the exponents.
- Multiply the significands.
- If required, normalise significand at the end.
- Select correct sign depending on values.
Division
Same as mult, but in step 1 subtract exponents and in set 2 divide significands.
Common Errors
- Overflow: magnitude is too large to store the format
- Underflow: magnitude is too small to store in the format Can often be confused with overflow in negative direction.
- Catastrophic cancellation: lack of significant figures to represent the result of colliding large and small numbers
- Lack of exact representations for common Base-10 numbers: