View Single Post
Re: Attempting to create float free engine
Old
  (#5)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Attempting to create float free engine - 01-01-2006

PHP Code:
// faster method to calculate 1.0/sqrt(f)
inline float InvSqrt(float f)
{
   
float half 0.5f f;

   
long lBits = *(long *)&f// evil floating point bit level hacking
   
lBits 0x5f3759df - (lBits >> 1); // WTF?
   
= *(float *)&lBits;
   
*= 1.5f half f// 1st iteration
//   f *= 1.5f - half * f * f; // 2nd iteration, this can be removed

   
return f;

also see the gcc and/or glibc source code
  
Reply With Quote