title: How to determine if a number is positive or negative?
body: <p>I was asked in an interview, how to determine whether a number is positive or negative. The rules are that we should not use relational operators such as <code>&lt;</code>, and <code>&gt;</code>, built in java functions (like <code>substring</code>, <code>indexOf</code>, <code>charAt</code>, and <code>startsWith</code>), no regex, or API's.</p>
  
  <p>I did some homework on this and the code is given below, but it only works for integer type. But they asked me to write a generic code that works for <code>float</code>, <code>double</code>, and <code>long</code>.</p>
  
  <pre><code> // This might not be better way!!
  
   S.O.P ((( number &gt;&gt; 31 ) &amp; 1) == 1 ? "- ve number " : "+ve number );
  </code></pre>
  
  <p>any ideas from your side?</p>