## 2.6 Data Representations     continued...

For example, in a 16-bit sign-magnitude system, the pattern 1000000011111111 represents the number and the pattern 0000000000000101 represents +5.

The other technique for representing both positive and negative integers is known as two's complement. It has two compelling advantages over the sign-magnitude representation, and is now universally used for integers, but as we will see below sign-magnitude is still used to represent real numbers. The two's complement method is based on the fact that binary arithmetic in fixed-length words is actually arithmetic over a finite cyclic group. If we ignore overflows for a moment, observe what happens when we add 1 to the largest possible number in an n-bit system (this number is represented by a string of n 1's):

The result is a pattern with a leading 1 and n 0's. In an n-bit system only the low order n bits of each result are saved, so this sum is functionally equivalent to 0. Operations that lead to sums with very large values ``wrap around'' to 0, i.e. the system is a finite cyclic group. Operations in this group are defined by arithmetic modulo 2.