title: How to return 1 if x*x can fit in a 32-bit integer, and 0 otherwise?
body: <p>I am working on a question and I am supposed to write a method  that 
  returns 1 if x*x can fit in a 32-bit integer, and 0 otherwise. 
  <br> 
  I thought that I could check if the number is larger than 46340 ( square root of the largest number that can be represented using 2's complement binary representation.) However I can't because I am limited to use upmost 255. </p>
  
  <pre><code> /*
   * squaredOK - Return 1 if x*x can 
  fit 
   in 
   a 32-bit integer, and 0 otherwise.
    *  Examples: squaredOK(10) = 1
   *            squaredOK(1000000) = 0
   *  Legal ops: ! ~ &amp; ^ | + - &lt;&lt; &gt;&gt;
   *  Max ops: 20
   */
  int squaredOK(int x) {
  
  return ; /* no idea */
  }
  </code></pre>
  
  <p>Okay after reading the comments I decided to add the limitations:
  use ONLY the following:</p>
  
  <ul>
  <li>Integer constants 0 through 255 (0xFF), inclusive. You are not allowed to use big constants such as 0xffffffff.</li>
  <li>Function arguments and local variables (no global variables).</li>
  <li>Unary integer operations ! ~</li>
  <li>Binary integer operations &amp; ^ | + &lt;&lt; >></li>
  </ul>