Created
April 9, 2014 05:52
-
-
Save charlietuna/10229806 to your computer and use it in GitHub Desktop.
Improved (over John Carmack's) inverse square root hack from Řrřola - http://rrrola.wz.cz/inv_sqrt.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float inv_sqrt(float x) | |
{ | |
union { float f; uint32 u; } y = {x}; | |
y.u = 0x5F1FFFF9ul - (y.u >> 1); | |
return 0.703952253f * y.f * (2.38924456f - x * y.f * y.f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment