#include<stdio.h> #include<conio.h> void main() { unsigned int m=32; printf("%x",~m); } sir please reply to my posts(I have posted 6 posts for output) it's urgent for me no one is replying why? please please answer to my threads
What is the question / doubt with regard to this program where you are displaying the value in hex after inverting the bits ?
sir printf("%x",~m); it will print (~m) value in hexa decimal system please explain me the output with explanation
output will be ==> ffdf its just complement of 0000 0000 0010 0000 or (0020 in hex or 32 in int/unsigned) i.e 1111 1111 1101 1111 (ffdf in hex or 65503 in unsigned or -33 in int)
thank u sir but i think when we are taking complement we invert all the bits but we will not invert sign bit is it crct or not
in C 2's complement method is used to represent numbers because of that when you say -1 its not 1000 0000 0000 0001 but 1111 1111 1111 1111 procedure to get this is 1.write magnitude of original number in binary format i.e. 1 instead of -1 0000 0000 0000 0001 2.now invert the bits i.e. (~number) 1111 1111 1111 1110 3.now add 1 to step 2 1111 1111 1111 1111 here the representation of -1, which is FFFF(1111 1111 1111 1111) and not 8001 (1000 0000 0000 0001).