views:

68

answers:

2

While learning about precision in floating point arithmetic and different methods to avoid it (using a conjugate, taylor series,...) books frequently mention the subtraction of two very similar numbers or one large and one small number as the biggest cause of error. How come it is only subtraction that causes this and not addition? As I see it you would still lose just as many significant bits while shifting.

+1  A: 

When subtracting two nearly-equal numbers, the difference will have fewer significant bits than the original numbers. A decimal example is:

 1.23456789    9 significant digits
-1.23456785    9 significant digits
───────────
          4    1 significant digit
dan04
A: 

There is no difference between addition or subtraction, subtraction is addition with the negated operand. You are correct, in order to add or subtract you have to shift the number with the smaller exponent off into the bit bucket in order to perform the operation resulting in fewer significant bits for that operand. If the exponents are more different than the size of the mantissa then addition or subtraction you get the number with the larger exponent as the result, all the bits of the smaller number have shifted off into the bit bucket N + 0 = N - 0.

dwelch