I\'m in a computer systems course and have been struggling, in part, with Two\'s Complement. I want to understand it but everything I\'ve read hasn\'t brought the p
In simple term 2's Complement
is a way to store negative number in Computer Memory. Whereas Positive Numbers are stored as Normal Binary Number.
Let's consider this example,
Computer uses Binary Number System
to represent any number.
x = 5;
This is represented as 0101
.
x = -5;
When the computer encouters -
sign, it computes it's 2's complement and stores it.
i.e
5 = 0101 and it's 2's complement is 1011
.
Important rules computer uses to process numbers are,
1
then it must be negative
number.0
then it is a positive number
because there is no -0
in number system.(1000 is not -0
instead it is positive 8
)0
then it is 0
.positive number
.