#### Sign-Magnitude

##### Format

The sign-magnitude binary format is the simplest conceptual format for expressing signed (positive and negative) integers. To represent a number in sign-magnitude, we simply use the leftmost bit to represent the sign, where 0 means positive and 1 means negative, and the remaining bits to represent the magnitude (absolute value).

A 8-bit sign-magnitude number would appear as follows:

Table 14.10. 8-bit sign-magnitude format

SignMagnitude
Bit 7Bits 6-0

##### Negation

To negate sign-magnitude numbers, simply toggle the sign bit. Note that this leads to having two representations for the number zero, +0 = 00000000 and -0 = 10000000.

##### Conversions

What are the decimal values of the following 8-bit sign-magnitude numbers?

• 10000011SM = -(2 + 1) = -3
• 00000101SM = +(4 + 1) = 5

Represent the following in 8-bit sign-magnitude:

• -15 = -(8 + 4 + 2 + 1) = 10001111
• +7 = +(4 + 2 + 1) = 00000111

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.

##### Range

Since the magnitude is an unsigned binary integer, range is computed as it is for unsigned binary, but with one bit fewer. Hence, for 8-bit sign-magnitude, the magnitude is a 7-bit unsigned integer and the range is therefore +/-27-1. In general, the range of an N-bit sign-magnitude number is +/-2N-1-1.

##### Comparison

Comparison works as with unsigned binary if the signs are the same. If the signs differ, the positive value is larger.

### Note

Be sure to thoroughly review the instructions in Section 2, “Practice Problem Instructions” before doing the practice problems below.
1. Perform the following conversions.

1. 11111111 8-bit SM to decimal

2. 01111111 8-bit SM to decimal

3. -7 decimal to 8-bit SM