>Is there a palm c function that returns the square root of a float?
>If not, does anyone have an algorithm that would work.  I want to

Try this one.

Regards,
Steve Mann

# # #


/*****************************************************
__sqrt

Calculate the square root of a double number.
*****************************************************/

double __sqrt ( double number ) {

        double  result = ZERO, square = ZERO, diff = ZERO;
        UInt            cnt = 0;


// eliminate negatives and zeros

        if ( number <= ZERO ) result = ZERO;
        else {

                result = number;        // initial approximation

// loop until required precision is attained or loop counts out

                do      {
                        result = ( result + number / result ) / TWO;
                        cnt++;
                        square = result * result;       // only for
calculating termination
                        diff   = square - number;
                } while (( diff > ZERO ) && ( cnt < 30 )) ;
        }

        return result;
}


-------------------------------------------
Creative Digital Publishing Inc.
1317 Palm Street, San Luis Obispo, CA 93401-3117
-------------------------------------------
805.788.0138            805.593.3811 (fax)
[EMAIL PROTECTED]       http://www.cdpubs.com


Reply via email to