Fast inverse square root, sometimes referred to as Fast InvSqrt() or by the hexadecimal constant 0x5f3759df, is an algorithm that estimates 1/√x, the reciprocal (or multiplicative inverse) of the square root of a 32-bit floating-point number x in IEEE 754 floating-point format.
The algorithm is best known for its implementation in the source code of Quake III Arena to compute angles of incidence and reflection of the light.
- Wikipedia -
Run the following from the command line:
node Q_rsqrt.js <number>
Esample (from Wikipedia):
node Q_rsqrt.js 0.15625
Output: 2.5254863388218056