I have mentioned the questions in which i have doubts . Kindly help me figure out the right answers with a bit of explanation
Q12. bitmask ~
int x = ~10;
What will be the value of x?
10
-10
-11
11
Q9. bitmask 1<<32 32 bit
long long x = (1 << 32) ;
What will be the value of x ?
2^32
Compilation Error
2^31
None of the above
Q7. bitmask power of 2
bool get(int x)
{
return (x && !(x & (x - 1)));
}
Above function will return :-
false if X is a power 2
true if X is a power 2
true if X is a perfect square of some integer
true if X is a not a perfect square of some integer
Q4. bitmask index of on lsb
Which one line function can be used to get index of the least significant bit that is on (first 1 from right to left in binary representation of an integer) ?
log2( N ^ -N ) + 1
log2( N | -N ) + 1
log2( N & -N ) + 1
log2( N ~ -N ) + 1