0

hi, please please give me exact explanation for the tilt symbol in c....
here i have paste the code and i m getting the output of 1... how it comes 1..?please explain me soon...

#include<stdio.h>
main()
{
int m=1;
~~~m;
printf("%x\n",m);
}
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by caroll
0

Well, the real story is you never write ~~~m back to m to print it out so you're getting your old value.

As for ~ it inverts the bits of an integer (bitwise not), so assuming a 32 bit integer:
m = 00000000 00000000 00000000 00000001
~m = 11111111 11111111 11111111 11111110
~~m = 00000000 00000000 00000000 00000001
~~~m = 11111111 11111111 11111111 11111110

Which equals -2 due to the signed nature of the integer and 2s -complements (check that out on Wikipedia if you're curious).

0

i cant get u... can u explain it in an easy way... i mean the complements.

1

>can u explain it in an easy way... i mean the complements
Bits go flip floppy.

Votes + Comments
Nice!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.