Fast inverse square root, the function that revolutionized 3D games industry:
float Q_rsqrt(float number) {
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * (long *) &y; //evil floating point bit lvl hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * (float *) &i;
y = y * (threehalfs - (x2 * y * y));
return y;
}
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin.
Back in the day, I had a geekcode which I'm not going to share with you.
418 I'm a teapot.
Fast inverse square root, the function that revolutionized 3D games industry:
I didn't get a damn thing, but that one is just beautiful
It's cool, but I wouldn't ever call it "elegant"!