Adding floating point numbers is very similar to adding fractions. If you have to fractions 1/2 and 2/4 you have to bring both numbers to the same denominator and add the numerators: 1/2 + 2/4 = 2/4 + 2/4 = 4/4 = 1/1 =1. For a floating point number,which is in normalized

IEEE 754 style ((-1)^(

sign) * (1 +

mantissa) * 2^ (

exponent - 127)), this works the same, you adjust the

exponent, add the

significants and reduce (

normalize) it.

The exact steps are: Choose the number with the smaller exponent, shift the exponent n-times, until it is equal to the other number's exponent. Now shift the significant n times right (remember: the 1 before decimal point is not saved in the mantissa, but it must be included in shifting: If your mantissa looks like 010...0 and you shift it by 1 bit, it must now look like 1010...0. The number is no longer normalized). Now you can simply add the both significants, after that you normalize the sum by left or right shifting (remember: shifting the significant in one direction means, that you have to shift the exponent in the other direction) and check for overflow or underflow. Now you have to round the sum using one of the four IEEE 754 rounding algorithms (rounding down, rounding up, rounding off or round to nearest even (standard), for more information go to IEEE 754 rounding modes ). After rounding you have to check if the result is still normalized.

**Be careful**: floating point addition is normally not associative ( (a+b)+c != a+(b+c) ), especially when working with large numbers and small numbers, the small number can be rounded away!

**Sources:**

Computer Organization & Design: The Hardware / Software Interface, David A. Patterson and John L. Hennessy, Morgan Kaufmann Publishers, San Francisco, California

Technische Grundlagen der Informatik II: Script, Prof. Dr. Michael GĂ¶ssel, University of Potsdam

Spim Tutorial: Einführung in die Assemblerprogrammierung mit MIPS, Reinhard Nitzsche, avaiable online

Grundlagen der Digitaltechnik, Prof. Dr.-Ing. Dr.-Ing h.c. Dr. h.c. Hans Martin Lipp, Oldenbourg Verlag, München and Wien

Technische Informatik I, Wolfram Schiffmann and Peter Schmitz, Springer Lehrbuch, Berlin

Spim Documentation, avaiable at http://www.cs.wisc.edu/~larus/spim.html