This is a way to print out a byte in binary. Since an int is more than one byte (usually two bytes or four bytes), the function can be easily changed to print out the whole int (change count=8 to count = 8*sizeof(int). If you know hexadecimal, it's easier to see by changing byte to various values like this:
int byte=0xff;
//int byte=0x80;
//int byte=0x77;
Code:
void binary_op( int byte )
{
int count=8;
int MASK = 1<<(count-1); //shift a one into the 8th bit position
while(count--) //loop 8 times
{
printf("%d", ( byte & MASK ) ? 1 : 0 );
//If there is a 1 at the bit position where mask has a 1, print a 1, else print a 0.
//So this prints starting with the most significant bit.
byte <<= 1; //Check the next bit
}
printf("\n");
}