Sunday, January 22, 2012

C Bitwise Questions

1.int main()
{
  printf("%x",-1<<4);
}
Output: fffffff0 [Dev C++ Compiler]
Explanation: -1 is internally represented as all 1's. When left shifted four times the
least significant 4 bits are filled with 0's.The %x format specifier specifies that the
integer value be printed as a hexadecimal value.

No comments:

Post a Comment