|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Floating point:
arithmetic |
|
|
|
|
Addition of floating
point numbers requires some adjustment if the exponents are not the same. |
|
|
Base 10: |
|
|
|
|
3.2 * 102 + 4.3 * 104 |
|
|
|
.032 * 104 + 4.3 * 104 |
|
|
|
4.3032 * 104 |
|
|
|
Does it matter which way
we adjust? |
|
|
|
|
|
|
IEEE754: |
|
|
|
|
1. Convert to scientific
notation |
|
|
|
2. Shift radix point so
exponents are the same (which way?) |
|
|
|
3. Add 2 mantissas (or
subtract if different signs) |
|
|
|
4. If sum does not have
a single 1 bit to the left of the radix point, shift and adjust exponent |
|
5. Determine sign |
|
|
|
|
6. Convert back to
floating point representation |
|
|
|
|
|
|
Multiplication actually
requires less adjustment: |
|
|
|
|
1.
Multiply mantissas |
|
|
|
|
2. Add exponents |
|
|
|
|
3. Determine sign |
|
|
|
4. Re-normalize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|