Reputation: 31
I'm trying to reduce the logic utilization for my FPGA and I can't find any good float fastpow online. By good I mean with a good reduction of logic utilized. If I use the double version I gain little improvement. If I use other float version that rely on log then again it's little. If I change the double version to float I gain a big reduction but then it doesn't work because results are quite bad. Is there anyone that knows a good approximation of pow for C code? (OpenCL)
Thanks
Upvotes: 0
Views: 253
Reputation: 31
Eventually I worked on the double version of fastPow and it works the same only using float data types just like this:
float fastPow(float a, float b) {
union {
float d;
int x;
} u = { a };
u.x = (int)(b * (u.x - 1072632447) + 1072632447);
return u.d;
}
Upvotes: 1