The sign-magnitude binary format is the simplest conceptual format. To represent a number in sign-magnitude, we simply use the leftmost bit to represent the sign, where 0 means positive, and the remaining bits to represent the magnitude (absolute value).
A 8-bit sign-magnitude number would appear as follows:
To negate sign-magnitude numbers, simply toggle the sign bit. Note that this leads to having two representations for the number zero.
What are the decimal values of the following 8-bit sign-magnitude numbers?
Represent the following in 8-bit sign-magnitude:
Addition and subtraction require attention to the sign bit. If the signs are the same, we simply add the magnitudes as unsigned numbers and watch for overflow. If the signs differ, we subtract the smaller magnitude from the larger, and keep the sign of the larger.
Since the magnitude is an unsigned binary number, range is computed as it is for unsigned binary, but with one less bit. Hence, for 8-bit sign-magnitude, the range is +/- 2^{7}-1.