> >If you know that the exponent is integral you may want to have a look at >GCC's __builtin_powi* functions. > >http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html > >You asked for a base of 2, maybe ldexp() fits your use case. > >Handling integral exponents separately will increase the code size >because the exponent must be checked at run time and extra code must be >executed in that case.
Tried an experiment with the the program that follow in studio to calculate the differences. int getVal () { return 3; } int main(void) { double d = __builtin_powi (7, getVal ()); double f = pow (7, getVal ()); while(1) { printf ("%f", d); printf ("%f", d); } } The builtin which called __powisf2 in libgcc. The code size and cycles obtained in avrstudio6 were as follows. Function Size Cycles pow 152 5525 __powisf2 210 452 Also the code in libc seems to have checks already to check if its integer so would calling the libgcc function be advisable ? -George- _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-libc-dev