By using this site, you agree to our Privacy Policy and our Terms of Use. Close
Kynes said:
Booh! said:

It's standard C, it doesn't take advantage of specific hardware, so yes it's high level. This is actually a point in favor of MikeB's point: this shows high algoritmic skill, but no hardware oriented programming skill (that's the worst part of modern CS).

i = 0x5f3759df - ( i >> 1 );

Is this standard C? In standard C you use the sqrt() function, you don't calculate the square root using magic numbers, ints and bit level (>>) functions to overcome a lack of float computing power in the Pentium 3/4 processors. This is as close to the metal as you can get in any high level language.

It works the same on every hardware, so it does not take advantage from the hardware. Have you got a pentium II? It works that way. Have you got a pentium 4? It works the same way. So it does not take advantage from the hardware, it just works the same on every hardware. BTW Pentium II, III and IV (which wasn't available when Q3 came out) all had floating point registers (SSE), so this is really not needed on those CPUs. This is just an optimization for the lowest hardware specification, that is it works the same on an old pentium MMX and on a (then) modern pentium 4, so it does not take advantage of the hardware.

That sqrt trick is just one of the billions tricks that acknowledged C programmer can use: http://www.azillionmonkeys.com/qed/sqroot.html . I programmed a bit in C and I used alot of tricks like this.