If your add code is correct and there is no subtraction, the problem seems to consist of two additions and additions.
Do I need to make two additions and addition, and not subtraction?
If this is not a problem, I am having problems with your algorithm. It has been a while since I did something like that. Could you provide some details? More specifically, what is a hidden bit?
It seems to me that processing a hidden bit is correct for adding, but not for subtracting. Maybe you should set it to f1 mantissa, not f2? Or deny f1 mantissa instead of f2?
Not knowing what you are getting against what you expect, and in more detail about the algorithm you are using, is the best I can do.
Edit: Ok, I looked at the links in your comment. One thing you do not do in the supplied code is normalization. When adding either an overflow of hidden bits (left shift of the mantissa, an increment indicator), or not. When subtracting, the arbitrary parts of the mantissa can be equal to zero. In decimal form, consider adding 0.5E1 and 0.50001E1; you will get 1.00001E1, and if you normalized, you would get 0.10001E2. Subtracting 0.5E1 from 0.50001E1 you get 0.00001E1. Then you need to move the mantissa to the left and reduce the exponent by as much as it takes to get 0.1E-4.
David thornley
source share