Old news but I just want to leave this here because I think it’s pretty cool. The function itself is like an artifact from another age. The article feels like a piece of ’software archeology’.

float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0×5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}


Fast Inverse Square Root
(PDF) by Chris Lomont