/. repost

Dec 01, 2006 12:44



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;
}This function appears in the Quake 3 source. It's reportedly about four times faster than 1.0/sqrt(x). There's a paper on how it works, and whence the magic number. Wow. (Link ( Read more... )

link, hacks, papers, programming

Leave a comment

Comments 3

benfrantzdale December 2 2006, 03:26:04 UTC
That is totally awesome.

Reply

mtbg December 2 2006, 03:28:16 UTC
I figured you'd appreciate it :D

Reply


macdaddyfrosh December 2 2006, 04:16:20 UTC
I liked the interview with the guy who wrote a special-purpose sqrt just for a fluid dynamics app...people really do this for a living?

Reply


Leave a comment

Up