Unique number generation using shift operator and validate same with the bitwise & operator in java
<p>I'm using LEFT SHIFT operator from java to generate some unique number and validate same with the bitwise &amp; operator like below.</p>

<pre><code>// Number generation 

public final static long UNIQUE_NUMBER8 = (long) 1 &lt;&lt; 8; 
public final static long UNIQUE_NUMBER9 = (long) 1 &lt;&lt; 9; 
public final static long UNIQUE_NUMBER10 = (long) 1 &lt;&lt; 10;
</code></pre>

<p>till</p>

<pre><code>public final static long UNIQUE_NUMBER62 = (long) 1 &lt;&lt; 62;
</code></pre>

<p>And validation of the same, I'm doing using below condition, 
where request_number is coming from the url, which is assigned to 
url the same generated number -</p>

<pre><code>if ( request_number &gt;= 0 &amp;&amp; (request_number &amp; UNIQUE_NUMBER10) != 0){
    System.out.println("Valid");
}else{
    System.out.println("Invalid");
}
</code></pre>

<p>But using above condition i'm not able to validate numbers above 1&lt;&lt; 62, 
since all the numbers till 62 are being used and above it will generate 
again same numbers which are already being used and 
hence the bitwise &amp; condition is failing.</p>

<p>Please help me too generate unique number using above or similar logic 
and validate same with the bitwise &amp; operator.</p>

<p>Thanks</p>
