title: How do I find whether a number is positive, negative or zero without using if or for?
body: <p>I want to implement the sign and zero flag setting in microprocessor. So I need to write a function to find whether the number is positive, negative or zero without using <code>if</code> or <code>for</code> loops and also <strong>only Boolean and bitwise operators are allowed</strong>. I did the following. But how to I implement it for <code>zero</code> condition ?</p>
  
  <pre><code>int status (int x) {
      int sign = (x &gt;&gt; 31);
      return sign;
  }
  </code></pre>
  
  <p>Any suggestions ?</p>