IT lexicon › Programming › Fast inverse square root

Fast inverse square root

Programming På svenska → Updated: 2026-10-26

The bit hack that approximates 1/√x by reading a float as an integer, subtracting it from a magic constant and polishing the result with one Newton step.

Games normalise vectors constantly — for lighting, reflections and physics — and every normalisation needs 1/√x. On 1990s CPUs both division and square root were slow. Q_rsqrt in Quake III Arena (1999) reinterprets the bits of an IEEE 754 float as an integer, where the exponent field means a right shift roughly halves the logarithm. Subtracting that from 0x5F3759DF yields a rough guess, and a single Newton–Raphson iteration brings the error under one percent.

It only became famous when id Software released the source in 2005, complete with the now-iconic comment // what the fuck?. Its lineage was later traced through 3dfx back to Greg Walsh at Ardent Computer. The same year the game shipped, x86 gained the rsqrtss instruction with SSE, so today the trick is mostly a museum piece.

← Back to the lexicon