Skip to content

Instantly share code, notes, and snippets.

@ianlevesque
Created October 22, 2009 06:25
Show Gist options
  • Save ianlevesque/215785 to your computer and use it in GitHub Desktop.
Save ianlevesque/215785 to your computer and use it in GitHub Desktop.
float InvSqrt (float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
return x*(1.5f - xhalf*x*x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment