fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main() {
  4. int a = -32768,i,b;
  5. b = -a; //negation
  6. // this loop will print the bit contents of b = -a;
  7. // that is 2's complement representation of a
  8. for(i = (sizeof(int)<<3) -1;i>=0;i--)
  9. (b&(1<<i)) ? printf("1"):printf("0");
  10. printf("\n");
  11. return 0;
  12. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
00000000000000001000000000000000