difference between (unsigned)1 and (unsigned)~0 in c
what is the difference between (unsigned)~0 and (unsigned)1.why is
unsigned of ~0 -1 and unsigned of 1 is 1? does it have something to do
with the way unsigned numbers are stored in the memory.why does an
unsigned number give a signed result.it dint give any overflow error
either. i used gcc
#include<sdio.h>
main()
{
unsigned int x=(unsigned)~0;
unsigned int y=(unsigned)1;
printf("%d\n",x); //prints -1
printf("%d\n",y); //prints 1
}
No comments:
Post a Comment