Nicolas Raitman wrote:
> 
> how can I do the following: a ^ b.
> I guess it is quite simple but I cannot find a function to do it.

What kind of numbers are you working with?

For floats you have to use "pow()" from the Math Libarary.

For Integers probably want to write your own. This one is quite fast:

WhatEver powInt( WhatEver a, Int b ) {
        WhatEver res = 1;
        Boolean neg = (b < 0);
        if( neg ) {
                if( a==0 ) error;
                b = -b;
        }
        while( b ) {
                if( b & 1 ) res *= a;
                a *= a;
                b = b >> 1;
        }
        if( neg ) res = 1/res;
        return res;
}


With kind regards / Mit freundlichem Gruß
    Holger Klawitter
--
Holger Klawitter
[EMAIL PROTECTED]                             http://www.klawitter.de


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to