Here is an explanation of why/how this works, if anyone is curious: http://h14s.p5r.org/2012/09/0x5f3759df.html

Keep in mind that on modern hardware, you don't want to actually use that function anymore, because CPUs have a built in instruction called rsqrtss which does an approximation to 11 bits, and it doesn't require the compiler to generate instructions to get the floating point out of the XMM registers and then later back in.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com