The unified diff between revisions [4cc7246c..] and [5a7404c7..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'fisqrt.c'
# # old_revision [4cc7246c1b6c809c9dc15997798f6deed15b3631] # new_revision [5a7404c7ee458d3eab4b0548e4bc6b6a8b26135f] # # add_file "fisqrt.c" # content [65553ed1491b6b3d4a266cc821c3f117c623a203] # ============================================================ --- /dev/null +++ fisqrt.c 65553ed1491b6b3d4a266cc821c3f117c623a203 @@ -0,0 +1,18 @@ +/* Implementation of fast inverse square root. + * See http://en.wikipedia.org/wiki/Fast_inverse_square_root + */ + +float fisqrt(float n) +{ + long i; + float x2, y; + + x2 = n * 0.5f; + y = n; + i = *(long *)&y; + i = 0x5f3759df - (i>>1); + y = *(float *)&i; + y = y * (1.5f - (x2*y*y)); + + return y; +}