On Tue, 4 Apr 2000 19:58:26, Thomas Wardwrites:
>> Have you done straight typecasting? Here is an example:
>>
>> Int32 i = 230000; // any number
>> double a = (double) i;
>> double b = Sqrt(a); // any Mathlib function that takes doubles
>> Int32 j = (Int32) b;
>
>Doh! That worked like a charm. Forest for the trees....
1. If you want to use MathLib in this manner you might want to
use the round(), ceil(), floor() or trunc() functions to make sure
you round in the manner your algorithms expect, rather than just
casting between float and integer types.
2. If you really just want integer results, using floating point
arithmetic/algorithms may not be the most efficient manner to
calculate these functions. For instance there are many nearest
integer square root algorithms that may run faster than just
the float to integer conversion that using MathLib requires.
Regards,
Ron Nicholson
HotPaw
http://www.hotpaw.com/rhn/hotpaw/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html