logancberrypie

Square Root algorithm

Jul 25th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1.         static void SQRT(float x)
  2.         {
  3.             float guess = 1.0f;
  4.             float current = 2;
  5.             while (guess != current)
  6.             {
  7.                 guess = current;
  8.                 current = (float)(0.5 * (guess + x / guess));
  9.             }
  10.             Console.WriteLine(current);
  11.         }
Advertisement
Add Comment
Please, Sign In to add comment