1,161 views
1 1 vote
int main()
{
unsigned int x = 1;
printf("Signed Result %d \n", ~x);
printf("Unsigned Result %ud \n", ~x);
return 0;

}

some one give detailed answer ...

(mainly how it works )

1 Answer

Best answer
2 2 votes

Output:-

Signed Result = -2

Unsigned Result = (4294967294)10

Explanation:-

Now, x = 1 in decimal 

and in binary 0000 0000 0000 0000 0000 0000 0000 0001

operator ~ is complement of given number.

1's complement of x = 1 --->>> 1111 1111 1111 1111 1111 1111 1111 1110

and its unsigned value is = 4294967294

For signed value use 2's complement notation. Computers uses 2's complement to represent negative numbers.

1111 1111 1111 1111 1111 1111 1111 1110  Representing in 2's complement notation gives -2.

• selected by
Position:
Show:

Related questions

0 0 votes
2 answers 2 answers
1.4k
1.4k views
Hira Thakur asked Jun 22, 2017
1,371 views
anyone explain this prog?? how to output is evaluvated??int main(){ int x = 10, y; y = (x++, printf("x = %d\n", x), ++x, printf("x = %d\n", x), x++); printf("y ...
1 1 vote
2 answers 2 answers
3.2k
3.2k views
ShiveshRoy asked Mar 25, 2016
3,199 views
Is set difference operator (-) used in relational algebra associative?