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?
f = *(float *)&lBits;
f *= 1.5f - half * f * 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