Anyone have a C routine or an snipit for returning a square root of a floating point number from a field Thanks
Here's a square root routine. I'll leave the exercise of how to get a string from a field and convert it to a double to you. There are plenty of examples in the archives, the Knowledgebase, and the SDK samples.
double sqrt ( double number )
{
double result = 0.0, square = 0.0, diff = 0.0;
UInt16 cnt = 0; if ( number <= 0.0 ) result = 0.0;
else {
result = number; // initial approximation
do
{
result = ( result + number / result ) / 2.0;
cnt++;
square = result * result;
diff = square - number;
} while (( diff > 0.0 ) && ( cnt < 30 )) ;
}return result; }
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
