17 static const float _2p23 = 8388608.0f;
21 uint32_t*
const pTable,
22 const uint32_t precision
26 float zeroToOne = 1.0f / ((float)(1 << precision) * 2.0f);
28 for( i = 0; i < (1 << precision); ++i )
31 const float f = ((float)powf( 2.0f, zeroToOne ) - 1.0f) *
_2p23;
32 pTable[i] = (uint32_t)( f <
_2p23 ? f : (
_2p23 - 1.0f) );
33 zeroToOne += 1.0f / (float)(1 << precision);
49 const uint32_t* pTable,
50 const uint32_t precision
54 const int32_t i = (int32_t)( (val * (
_2p23 * ilog2)) + (127.0f *
_2p23) );
57 const int32_t it = (i & 0xFF800000) | pTable[(i & 0x7FFFFF) >>
61 return *(
const float*)( &it );
static const float _2p23
http://www.hxa.name/articles/content/fast-pow-adjustable_hxa7241_2007.html
float powFastLookup(const float val, const float ilog2, const uint32_t *pTable, const uint32_t precision)
Get pow (fast!).
void powFastSetTable(uint32_t *const pTable, const uint32_t precision)