S
somenath
Hello All,
I am confused with the behaviour of the following program
#include<stdio.h>
int main(void)
{
printf("\n~0U = %d",~0U);
printf("\n~0 = %d",~0);
printf("\n~0U>>1 = %d",~0U>>1);
printf("\n~0>>1 = %d\n",~0>>1);
return 0;
}
==========
Output
=========
~0U = -1
~0 = -1
~0U>>1 = 2147483647
~0>>1 = -1
===========
According to my understanding ~0 is -1.So I will get all bit 1 as a
result of ~0 in 2's complement system.
So the first two line of output saying ~0 is same as ~0U. Then why
there is difference in the output of ~0U>>1 and ~0>>1 ?
please provide some input.
I am confused with the behaviour of the following program
#include<stdio.h>
int main(void)
{
printf("\n~0U = %d",~0U);
printf("\n~0 = %d",~0);
printf("\n~0U>>1 = %d",~0U>>1);
printf("\n~0>>1 = %d\n",~0>>1);
return 0;
}
==========
Output
=========
~0U = -1
~0 = -1
~0U>>1 = 2147483647
~0>>1 = -1
===========
According to my understanding ~0 is -1.So I will get all bit 1 as a
result of ~0 in 2's complement system.
So the first two line of output saying ~0 is same as ~0U. Then why
there is difference in the output of ~0U>>1 and ~0>>1 ?
please provide some input.