The Magic Number in Quake III Was Not John Carmack's
The most famous line of game-engine code has a comment that reads 'what the fuck?' Carmack didn't write it.
The line in question, from q_math.c in the 1999 Quake III Arena source: i = 0x5f3759df - ( i >> 1 ); // what the fuck?. The comment is in the shipped code. The function it lives in computes an inverse square root about four times faster than the standard library by reinterpreting a float's bits as an integer, doing one subtraction, then refining with a single Newton-Raphson step. For years, programmers credited John Carmack.
In April 2004, Beyond3D asked Carmack directly. He replied: "Not me, and I don't think it is Michael. Terje Matheson perhaps?" The trail led instead to Gary Tarolli, a 3dfx founder, who remembered seeing the trick at Silicon Graphics over a decade earlier but couldn't take credit either. "I remember running across it over 10 years ago," he wrote.
The authorship was finally resolved in 2006, when Greg Walsh emailed Beyond3D. Walsh had worked at Ardent Computer in the late 1980s, where his coworker Cleve Moler, the same Moler who built MATLAB, had passed him a bit-fiddling technique from an unpublished 1986 paper by William Kahan and K.C. Ng at Berkeley. Walsh refined the constant. Tarolli, consulting for Kubota (which funded Ardent), carried it to 3dfx. Brian Hook likely brought it from 3dfx to id Software.
So the most-quoted line of game-engine code is a 13-year game of telephone: a Berkeley numerical analyst's note, picked up by the author of MATLAB, refined by an engineer at a defunct supercomputer company, smuggled into a graphics card, and finally shipped in a shooter by a programmer who looked at it and wrote "what the fuck?" in the margin. He was right to.
Make Recess yours.
Sign in to save the ones you loved, never see the same thing twice, and tell us what you want more of.