Nabsha's Blog-About

Just another WordPress.com weblog

Fast Square Root Function/Routine

Below is a very fast square root function after reading this wonderful article .

This square root function only does 1 arithmetic operation and 1 bit shift operation and provides reasonably accurate approximation to the square root of positive integers.

 float FastSqrt(float x) {
 int i = *(int*)&x;
 i = 0x1fbd1df5 + (i >> 1);
 x = *(float*)&i;
 return x;
 }

Following is the plot for reference.

Leave a comment