Problems on Bit Manipulations
Check if two numbers have opposite sign We can use the operation if (x ^ y) < 0 where x and y are non zero numbers { True --- if numbers of opposite sign { False --- if numbers of same sign int x=-10,y=2; System.out .println(((x ^ y) < 0)); Output :- False Check if number is power of 2 We can use x & (x - 1)) == 0 True --- if numbers is a power of 2 False --- if numbers is not a power of 2 int x=16; System.out.println((x & (x - 1))==0); Output :- True More bitwise tricks x&(x-1) :---------------- Returns number x with the lowest bit set off x ^ ( x & (x-1 ) :---------...