Thomas, George schrieb:

Also adding to the points mentioned above, is it required to use
the logrithms for getting this done as we explicitly say the
second argument of pow should be an integer ?

This is rather an optimization for the compiler and than map pow to a powi something.

IIRC GCC performs that so the right agenda is to verify that GCC performs the transformation for a primary target like x86 and then find out why that it is not performed on avr.

Maybe a missing TARGET_C99_FUNCTIONS macro is the reason or because avr-gcc has non-ISO double.

My suggestion was handling the cases where power required is a whole
number or an integer separately so that accuracy for them can be
improved rather than going by the exponent method.

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.

Johann


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to