1. I was creating number that consists of these 2 bits (20th and 2nd)
2. I tryed to read exactly that 20th bit to see if its actually 1
Here is the code and the output i was getting.
Anyone knows why didnt i get my 1 or 0?
1 2
int x = 1048580; //This is number 2^20 + 2^2 so 1000000000....0010
cout << (x & (1 << (20)));
When you do (x & (1 << 20)), you are ending up with either 0 or (1 << 20) because you are not shifting the result at all. Note that (1 << 20) equals 1048576.