Reverse bits in number
<p>For example, I have the binary number 1011 which is equal to decimal 11. I want the reverse bit's location such that it become 1101, which is decimal 13. Here is code:</p>

<pre><code>import java.util.*;
public class bits {
    public static void main(String[] args) {
        Scanner scnr=new Scanner(System.in);
        System.out.println("enter x:");
        int x=scnr.nextInt();
        int b=0;
        while (x!=0){
            b|=( x &amp;1);
            x&gt;&gt;=1;
            b&lt;&lt;=1;
        }
        System.out.println(b);
    }
}
</code></pre>

<p>But when I enter x 11 then it prints 26. What is the mistake?</p>
