flâneur — a map of the web's best reading

githublog/2024/5/29/fast-inverse-sqrt.md at main · francisrstokes/githublog

github.com · 3,950 words · saved by 1 readers

I'm sick of complex blogging solutions, so markdown files in a git repo it is - francisrstokes/githublog

Everything I Know About The Fast Inverse Square Root Algorithm The fast inverse square root algorithm , made famous (though not invented) by programming legend John Carmack in the Quake 3 source code, computes an inverse square root $\frac{1}{\sqrt{x}}$ with a bewildering handful of lines that interpret and manipulate the raw bits of float. It's wild . float Q_rsqrt ( float number ) { long i ; float x2 , y ; const float threehalfs = 1.5F ; x2 = number * 0.5F ; y = number ; i = * ( long * ) & y ; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( flo

Explore this link on the map →

related reading