Saturday, December 02, 2006

I like this piece of clever code. You might too...

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;

1 comments:

Fuzzyman said...

Good to see you blogging again Terry. I mentioned you (probably unfairly) in a recent blog entry :

http://www.voidspace.org.uk/python/weblog/arch_d7_2006_11_25.shtml#e562