 <p>You want to be using the right shift operators (there are two) and shift thevalue <strong>right</strong>:</p> <pre><code>if ((input &gt;&gt;&gt; 24) == 0) { // high-order 40 bits are all 0. } </code></pre> <p>Alternatively, you can simply bit-mask with:</p> <pre><code>if ((input &amp; 0xFFFFFFFFFF000000L) == 0) { // high-order 40 bits are all 0. } </code></pre> <p>Note that <code>&gt;&gt;&gt;</code> will put 0 in the high-order bits, and <code>&gt;&gt;</code> will put 0 for positive numbers, and 1 for negative.</p>