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
related reading
- Fast Inverse Square Root — A Quake III Algorithmyoutube.com
- Math & Engineeringxn--2-umb.com
- Floating point from scratch: Hard Mode · Tales on the wireessenceia.github.io
- ⭐️ Fast LLM Inference From Scratchandrewkchan.dev
- A High-Level Technical Overview of Fully Homomorphic Encryption || Math ∩ Programmingjeremykun.com
- We reverse-engineered Flash Attention 4modal.com
- Binius: highly efficient proofs over binary fieldsvitalik.eth.limo
- Ken Shirriff's blogrighto.com
- Quantization from the ground upngrok.com
- Your Transformer is Secretly an EOT Solver | Elements of a Vector Spaceelonlit.com
- GitHub - Experience-Monks/math-as-code: a cheat-sheet for mathematical notation in code formgithub.com
- There are Only Four Billion Floats-So Test Them All! | Random ASCII – tech blog of Bruce Dawsonrandomascii.wordpress.com