Computer Science Canada

A Brief History of InvSqrt

Author:  matt271 [ Wed Mar 28, 2012 5:16 pm ]
Post subject:  A Brief History of InvSqrt

Just finished my Honours Thesis about the fast InvSqrt function found in Quake III,

c:
float Q_rsqrt(float number) {
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y = number;
    i = *(long *) &y;
    i = 0x5f3759df - (i >> 1);
    y = *(float *) &i;
    y = y * (threehalfs - (x2 * y * y));
//  y = y * (threehalfs - (x2 * y * y));

    return y;
}


http://eggroll.unbsj.ca/rsqrt/

Questions, comments, suggestions?

Author:  Dreadnought [ Wed Mar 28, 2012 6:22 pm ]
Post subject:  Re: A Brief History of InvSqrt

Wow, that's so amazing! It's probably the coolest (and weirdest) function I've ever seen.

Nice job, on the thesis too, it was fun to read.

Btw, if you plan on printing from that pdf, some of the numbers in the appendix run off the page.

Author:  matt271 [ Wed Mar 28, 2012 6:41 pm ]
Post subject:  Re: A Brief History of InvSqrt

Thanks for the tip! I will fix it before I give print outs to my readers tomorrow!

Author:  matt271 [ Wed Sep 11, 2013 9:38 pm ]
Post subject:  RE:A Brief History of InvSqrt

Complete version, for anybody who's interested...

http://shelfflag.com/rsqrt.pdf


: