In bitwise mathematics
, an important and recurring
theme in the storage
is the concept of the one's complement.
The concept itself is rather simple, take all existing bits and flip their value. Of course, since computers deal only in binary, we make every 0 into a 1, and every 1 into a 0. Another way to think about this, is to subtract the number you have from a string of 1's. For example, if we have the bitstring 10011001:
1 1111 1111
- 1001 1001
Thus, our result is 01100110. Note: It is important to keep the leading zero in this instance, due to rules of byte
storage and problems arrising if we were to try to reverse the process. If we truncate
our zero, we do not get the same result if we take the one's complement again, as shown:
01100110 = 1100110, flip the bits, 0011001. 11001 is not equivalent to 10011001 by any means.
See also: two's complement