fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. char a = 0xAA;
  5. unsigned char b = 0xBB;
  6.  
  7. printf("char a = 0xAA;\n");
  8. printf("unsigned char b = 0xBB;\n");
  9. printf("\n");
  10. printf(" 0x%X\t ~ a\n", a);
  11. printf(" 0x%X\t ~ b\n", b);
  12. printf("\n");
  13. printf(" 0x%X\t ~ (char) a\n", (char) a);
  14. printf(" 0x%X\t ~ (char) b\n", (char) b);
  15. printf("\n");
  16. printf(" 0x%X\t ~ (signed char) a\n", (signed char) a);
  17. printf(" 0x%X\t ~ (signed char) b\n", (signed char) b);
  18. printf("\n");
  19. printf(" 0x%X\t ~ (unsigned char) a\n", (unsigned char) a);
  20. printf(" 0x%X\t ~ (unsigned char) b\n", (unsigned char) b);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
char          a = 0xAA;
unsigned char b = 0xBB;

    0xFFFFFFAA	 ~ a
    0xBB	 ~ b

    0xFFFFFFAA	 ~ (char) a
    0xFFFFFFBB	 ~ (char) b

    0xFFFFFFAA	 ~ (signed char) a
    0xFFFFFFBB	 ~ (signed char) b

    0xAA	 ~ (unsigned char) a
    0xBB	 ~ (unsigned char) b