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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: