|Amiga Research OS|
AROS - The Amiga Research OS
- #include <libraries/mathffp.h>
float SPAdd ()
- float fnum1
- Calculate the sum of two ffp numbers
- FFP number
- FFP number
- sum of fnum1 and fnum2.
- result is zero
- result is negative
- result is too large or too small for ffp format
- SEE ALSO
Adapt the exponent of the ffp-number with the smaller
exponent to the ffp-number with the larger exponent.
Therefore rotate the mantisse of the ffp-number with the
smaller exponents by n bits, where n is the absolute value
of the difference of the exponents.
The exponent of the target ffp-number is set to the larger
exponent plus 1.
Additionally rotate both numbers by one bit to the right so
you can catch a result > 1 in the MSB.
If the signs of the two numbers are equal then simply add
the two mantisses. The result of the mantisses will be
[0.5 .. 2[. Check the MSB. If zero, then the result is < 1
and therefore subtract 1 from the exponent. Normalize the
mantisse of the result by rotating it one bit to the left.
Check the mantisse for 0.
If the signs of the two numbers are different then subtract
the ffp-number with the neagtive sign from the other one.
The result of the mantisse will be [-1..1[. If the MSB of
the result is set, then the result is below zero and therefore
you have to calculate the absolute value of the mantisse.
Check the mantisse for zero. Normalize the mantisse by
rotating it to the left and decreasing the exponent for every
Test the exponent of the result for an overflow.
Amiga® is a trademark of Amiga Inc. All other trademarks belong to their respective owners.
Copyright © AROS - The Amiga Research OS
All Rights Reserved
Comments to webmaster: firstname.lastname@example.org
Generated: Tue Sep 4, 2001