2 Jun
2003
2 Jun
'03
12:29
On Mon, 2 Jun 2003 01:23:51 -0400 (PYT) Raúl Gutiérrez Segalés <rau@campoalto.edu.py> wrote:
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 <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9