## 2.6 Data Representations     continued...

For our purposes, what is interesting about this type of arithmetic is that , which is represented by a 1 followed by n 0's, is equivalent to 0, which means for all x between 0 and . A simple ``trick'' that has its roots in this fact can be applied to the bit pattern of a number in order to calculate its additive inverse: if we invert every bit (turn a 1 into a 0 and vice versa) in the representation of a number x and then add 1, we come up with the representation of - x. For example, the representation of 5 in an 8-bit system is 00000101. Inverting every bit and adding 1 to the result gives the pattern 11111011. This is also the representation of 251, but in arithmetic modulo 2 we have so this pattern is a perfectly acceptable representation of -5 (see problem 7).

In practice we divide all n-bit patterns into two groups. Patterns that begin with 0 represent the positive integers and patterns beginning with 1 represent the negative integers . To determine which integer is represented by a pattern that begins with a 1, compute its complement (invert every bit and add 1). For example, in an 8-bit two's complement system the pattern 11100001 represents , since the complement is . Note that the leading bit determines the sign, just as in a sign-magnitude system, but one cannot simply look at the remaining bits to ascertain the magnitude of the number. In a sign-magnitude system, the same pattern represents -97.