AROSAmiga Research OS

Previous Next Top of Manual blank.gif

AROS - The Amiga Research OS


Documentation
    AutoDocs
        Exec.library
        MathFFP.library
        MathIEEEDoubleBase
        MathIEEEDoubleTrans
            IEEEDPPow
            IEEEDPTieee
            IEEEDPAtan
            IEEEDPSincos
            IEEEDPExp
            IEEEDPLog
            IEEEDPFieee
            IEEEDPSqrt
            IEEEDPTanh
            IEEEDPCosh
            IEEEDPCos
            IEEEDPAsin
            IEEEDPLog10
            IEEEDPSin
            IEEEDPSinh
            IEEEDPAcos
        MathIEEESingleBase
        MathIEEESingleTrans
        MathTrans
NAME
#include <aros/libcall.h>
#include <proto/mathieeedoubbas.h>
#include <proto/mathieeedoubtrans.h>
#include <proto/exec.h>
#include <exec/types.h>

double IEEEDPSqrt ()

SYNOPSIS
double y

FUNCTION
Calculate square root of IEEE double precision floating point number
INPUTS
y
IEEE double precision floating point number

RESULT
Motorola fast floating point number flags: zero : result is zero negative : 0 overflow : square root could not be calculated
NOTES
EXAMPLE

BUGS
SEE ALSO
MathIEEEDoubleTrans

INTERNALS
ALGORITHM:

First check for a zero and a negative argument and take appropriate action.

fnum = M * 2^E

Exponent is an odd number:


fnum = ( M*2 ) * 2^ (E-1)
Now E' = E-1 is an even number and
-> sqrt(fnum) = sqrt(M)   * sqrt(2)   * sqrt (2^E')
= sqrt(M)   * sqrt(2)   * 2^(E'/2)
(with sqrt(M*2)>1)
= sqrt(M)   * sqrt(2)   * 2^(E'/2)
= sqrt(M)   * 1/sqrt(2) * 2^(1+(E'/2))
= sqrt(M/2)             * 2^(1+(E'/2))

Exponent is an even number:

-> sqrt(fnum) = sqrt(M) * sqrt (2^E) =
= sqrt(M) * 2^(E/2)

Now calculate the square root of the mantisse. The following algorithm calculates the square of a number + delta and compares it to the mantisse. If the square of that number + delta is less than the mantisse then keep that number + delta. Otherwise calculate a lower offset and try again. Start out with number = 0;


Exponent = -1;
Root = 0;
repeat
{
if ( (Root + 2^Exponent)^2 < Mantisse)
Root += 2^Exponent
Exponent --;
}
until you`re happy with the accuracy


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