2.1 fp
This exercise is optional.
Refer to the exercise policy for details.
Write a C program that adds two 32-bit floating point numbers without
using the hardware’s floating point unit (i.e. using only C’s integer
operations.) You should not reimplement scanf though, because
it is way too painful. In addition, I recommend focusing only on
positive floating point numbers with no more than six (6) significant
digits and between +10^-37 and +10^37.
Here’s some advice about how to do this: First, copy the mantissa
values and expose the hidden bits so you have a 24-bit value rather
than a 23-bit value. Second, shift the mantissa of the smaller value
while decrementing the exponent until the exponents are equal. Third,
add the mantissa values. Fourth, construct a new emulated float with
the added mantissa and the common exponent. These first four steps are
just a matter of C bit-twiddling. The hard part will come from dealing
properly with removing the hidden bit, dealing with carrying during
addition, and ensuring that you shift values correctly.