Get wrong answer in bitwise and on unsigned int on c?

86 Views Asked by At

I have two numbers, 2147483648 and 808529920 stored in unsigned int variables but, when I do their bitwise and in C, the answer is supposed to be 1, but I get 0.

808529920 in binary looks like:

110000001100010011000000000000

2147483648 in binary looks like:

10000000000000000000000000000000
unsigned int a = 808529920;
unsigned int b = 2147483648;

unsigned int ret = a & b;
1

There are 1 best solutions below

2
On
 808529920 == 0b00110000001100010011000000000000
2147483648 == 0b10000000000000000000000000000000

There are no bits in common, so you should get 0 not 1.