Complements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Complements

explain me the concept of 2's complement with signed values in C

7th Dec 2017, 7:26 AM
Hema Chander
Hema Chander - avatar
4 Answers
+ 7
a positive binary number can be written like that : 0111 (for 7) The last bit (here 0) is the signed bit. The 2's complement is : 1's complement then add 1 1's complement of our number : 1000 1000 + 1 = 1001 So -7 is written 1001
7th Dec 2017, 7:53 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
~7 is 1's complement (~7) + 1 is 2's complement
7th Dec 2017, 4:06 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
how can we say -7 as 1001?? need more explanation
7th Dec 2017, 12:24 PM
Hema Chander
Hema Chander - avatar
0
is ~7 and 2's complement of 7 same in binary or do we have any relation among it.
7th Dec 2017, 12:28 PM
Hema Chander
Hema Chander - avatar