Can someone explain this ((A[j] >> i) & 1) please?


#1

what does this mean:
((A[j] >> i) & 1)


#2

All it means is, when you right shift the number by ‘i’ what would be the first bit? Suppose your number is 5 whose binary rep. is 101. When you right shift 5 by 1, the it would be 010. 010&1 would be 0 (since 0&1=0). If 5>>2, then 001. 001&1 is 1. Following this procedure, you’d be able to extract each bit in the number.


#3

In other words you can also interpret it as A[j] divided by 2^i, then checking if it has 1 in the lowest bit (or it is odd)