2 Jun
2003
2 Jun
'03
12:29
On Mon, 2 Jun 2003 01:23:51 -0400 (PYT)
Raúl Gutiérrez Segalés
Hi,
I am trying to do a NOT operation but it doesnt seem to work well:
unsigned int i=8;
printf("%d \n", ~i);
This is suppose to print 247 but I get -9
Any ideas of what am I doing wrong ?
BTW, I am just practicing on playing with bits..
This has been answered correctly.
printf("%u \n", ~i);
The %u prints unsigned.
You start with 0000 0000 0000 0000 0000 0000 0000 1000
You should end up with
11111111111111111111111111110111.
You might understand things better if you use %x also.
--
Jerry Feldman