0
is ~7 and 2's complement of 7 same in binary or do we have any relation among it.
3 Answers
+ 3
I'm sorry I misspoke.
An integer number in most computers usually consists of a sign bit and some stuff after. For example the number 7, stored in an 8-bit char:
0 0000111 // 7
The one's complement, ~7, is obtained by flipping every bit:
1 1111000 // ~7
Almost all computers use two's complement integers though. So if you want to make a number negative, you take one's complement and add 1.
1 1111001 // ~7 + 1 == -7
+ 2
And by the way, computers don't use one's complement for negative numbers because then the number 0 (binary 0 0000000) and ~0 == -0 (binary 1 1111111) would be different, but clearly 0 and -0 are the same number.
0
need more explanation