integer with character?

I am looking at the accepted answer provided here:

http://stackoverflow.com/questions/1024389/print-an-int-in-binary-representation-using-c

It uses this one line:

(a & 1) + '0';

Why is it adding the result of the bitwise AND with a '0' character?
The bitwise and returns 1 if bit 0 is set else it returns 0. Adding '0' will give the char value of the 0 or 1.
I thought bitwise-AND operates on each bit, not just bit 0. I thought it operates on all 32 bits of an integer in 32-bit system and returns a new value where all on bits between the two numbers remain on, otherwise off. Like in the following:
1
2
3
     11001110
   & 10011000
   = 10001000


As you see in above example, bit 0 is not set, but it still returns a value greater than 0, which is 136 (10001000) in this case. Am I missing something?
In that example you are anding with more than just one bit so, yes it does operate on all of the bits. But (a & 1) is more like:

   11001110
  &00000001
  =00000000
Still confused because a is a 32-bit integer and 1 is a 32-bit integer. So why would it AND only 1 bit and not all 32?
Wait I think I know why i was confused. I was confusing 1 with 255. 1 is 00000001 not 11111111.
Topic archived. No new replies allowed.