// Show C int to byte casting #include void PrintBitsInt(int x) { int i; for (i = 31; i >= 0; i--) if ( (x & (1 << i)) != 0 ) printf("1"); else printf("0"); } void PrintBitsByte(char x) { int i; for (i = 7; i >= 0; i--) if ( (x & (1 << i)) != 0 ) printf("1"); else printf("0"); } void main() { int i = 4100; char b; b = (char) i; // Casting is OPTIONAL !!! printf("i = %d\t" , i); PrintBitsInt(i); printf("\n\n"); printf("b = %d\t" , b); PrintBitsByte(b); printf("\n\n"); }