AROSAmiga Research OS

Previous Next Top of Manual blank.gif

AROS - The Amiga Research OS


Documentation
    AutoDocs
        Exec.library
        MathFFP.library
            SPAdd
            SPCmp
            SPMul
            SPAbs
            SPCeil
            SPDiv
            SPNeg
            SPTst
            SPFloor
            SPFix
            SPSub
            SPFlt
        MathIEEEDoubleBase
        MathIEEEDoubleTrans
        MathIEEESingleBase
        MathIEEESingleTrans
        MathTrans
NAME
#include <libraries/mathffp.h>
#include <proto/mathffp.h>

float SPAdd ()

SYNOPSIS
float fnum1
float fnum2

FUNCTION
Calculate the sum of two ffp numbers
INPUTS
fnum1
FFP number
fnum2
FFP number

RESULT
sum of fnum1 and fnum2. Flags:

zero
result is zero
negative
result is negative
overflow
result is too large or too small for ffp format

NOTES
EXAMPLE

BUGS
SEE ALSO
MathFFP.library

INTERNALS

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 rotation.

Test the exponent of the result for an overflow. That`s it!


Previous Next Top of Manual blank.gif
minilogo.gif

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: digulla@aros.org
Generated: Tue Sep 4, 2001