title: How to find TMax without using shifts
body: <p>Using ONLY</p>
  <pre><code> ! ~ &amp; ^ | +
  </code></pre>
  <p>How can I find out if a 32 bit number is TMax?</p>
  <p>TMax is the maximum, two's complement number.</p>
  <p>My thoughts so far have been:</p>
  <pre><code>int isTMax(int x)
  {
    int y = 0;
    x = ~x;
    y = x + x;
    return !y;
  }
  </code></pre>
  <p>That is just one of the many things I have unsuccessfully have tried but I just cant think of a property of TMax that would give me TMax back. Like adding tmax to itself would be unique compared to all the other integers.</p>
  <hr />
  <p>Here is the actual problem:</p>
  <pre><code>/*
   * isTMax - return 1 if x is the maximum, two's complement number,
   *     and 0 return otherwise. 
   *   Legal ops: ! ~ &amp; ^ | +
   *   Max ops: 10
   *   Rating: 1
   */
  int isTMax(int x) {
    int y = 0;
    x = ~x;
    y = x + x;
  
    return !y;
  }
  </code></pre>
  <p>int is 32 bits so the max signed would probably be 0x7FFFFFFF</p>