|
From: | Georg-Johann Lay |
Subject: | Re: [avr-libc-dev] Pow Function in avr8 |
Date: | Thu, 29 Nov 2012 09:29:12 +0100 |
User-agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |