Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 811 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 811 Bytes

Q_rsqrtJS

This is a simple JavaScript implementation of the Fast inverse square root.

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 -

Complete Wikipedia article


How to use:

Run the following from the command line:

node Q_rsqrt.js <number>

Esample (from Wikipedia):

node Q_rsqrt.js 0.15625
Output: 2.5254863388218056