Label Cloud

Monday, December 04, 2006

Fast Inverted Square - 1/sqrt(x)

How fast is it ?

float InvSqrt (float x) {
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}

0 comments:

About

My photo
Taipei, Taiwan
3rd Year Ph.D Student in Chemical Biology and Biological Physics of Academia Sinica

Google Analytics