Skip to content

Instantly share code, notes, and snippets.

@designerzen
Created September 4, 2022 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designerzen/11e655fa5e9d07eece4aed2307f50b22 to your computer and use it in GitHub Desktop.
Save designerzen/11e655fa5e9d07eece4aed2307f50b22 to your computer and use it in GitHub Desktop.
Fastest inverse square root
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