Inverse Square Root
I just bumped into a clever little code snippet used to find the inverse square root: float InvSqrt(float x){ float xhalf = 0.5f * x; int i = *(int*)&x; // store floating-point bits in integer i = 0x5f3759d5 – (i >> 1); // initial guess for Newton’s method x = *(float*)&i; // convert new bits [...]
Filed under: Share, Technology, gaming by Loki
View Comments