title: What's a good algorithm to determine if an input is a perfect square?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer">Fastest way to determine if an integer&#39;s square root is an integer</a>  </p>
  </blockquote>
  
  
  
  <p>What's a way to see if a number is a <a href="http://en.wikipedia.org/wiki/Square_number" rel="noreferrer">perfect square</a>?
  </p>
  
  <pre class="lang-cs prettyprint-override"><code>bool IsPerfectSquare(long input)
  {
     // TODO
  }
  </code></pre>
  
  <p>I'm using C# but this is language agnostic.</p>
  
  <p>Bonus points for clarity and simplicity (this isn't meant to be code-golf).</p>
  
  <hr>
  
  <p><strong>Edit:</strong> This got much more complex than I expected! It turns out the problems with double precision manifest themselves a couple ways. First, Math.Sqrt takes a double which can't precisely hold a long (thanks Jon). </p>
  
  <p>Second, a double's precision will lose small values ( .000...00001) when you have a huge, near perfect square. e.g., my implementation failed this test for Math.Pow(10,18)+1 (mine reported true).</p>