Code

Fast power-of-10 approximation, for 32-bit floats

January 31, 2011 Coded in C for the SHARC

Fast floating-point power-of-10 approximation, with RMS error of 1.77%. 
This approximation developed by Nicol Schraudolph (Neural Computation vol 11, 1999). 
Adapted for 32-bit floats by Lippold Haken of Haken Audio, April 2010.

// Fast power-of-10 approximation, with RMS error of 1.77%. 
// This approximation developed by Nicol Schraudolph (Neural Computation vol 11, 1999).  
// Adapted for 32-bit floats by Lippold Haken of Haken Audio, April 2010.
// Set float variable's bits to integer expression.
// f=b^f is approximated by
//   (int)f = f*0x00800000*log(b)/log(2) + 0x3F800000-60801*8
// f=10^f is approximated by
//   (int)f = f*27866352.6 + 1064866808.0
inline void Pow10(float *f) { *(int *)f = *f * 27866352.6 + 1064866808.0; };