Sign-magnitude Representation

Learn the simplest representation of the signed and unsigned integers in computer memory.

Ways to use SMR

All numbers in the computer’s memory are represented in binary form. This means that the computer stores them as a sequence of zeros and ones. A number representation defines how to interpret this sequence.

First, we consider the simplest numbers representation that is the sign-magnitude representation or SMR. There are two ways to use it:

  1. To store positive integers (unsigned).

  2. To store both positive and negative integers (signed).

Sign-magnitude representation

Unsigned integers

The computer allocates a fixed block of memory for any number. When we apply SMR to store a positive integer, all allocated memory bits are used in the same way. They store the value of the number. The table shows several examples of how it looks.

Decimal Hexadecimal SMR
0 0 0000 0000
5 5 0000 0101
60 3C 0011 1100
110 6E 0110 1110
255 FF 1111 1111

Let’s suppose that the computer allocates one byte of memory for a number. Then, we can store unsigned integers from 0 to 255 there using SMR.

Signed integers

The second option of SMR allows us to store signed integers. In this case, the highest bit keeps the integer’s sign. Therefore, there are fewer bits left for the value of the number.

Here’s an example. Let’s suppose that a computer allocates one byte to store the signed integer. One bit is reserved to indicate the positive or negative sign. Then, we have seven bits only to store the number itself.

The following table shows the sign-magnitude representation of several signed integers.

Decimal Hexadecimal SMR
-127 FF 1111 1111
-110 EE 1110 1110
-60 BC 1011 1100
-5 85 1000 0101
-0 80 1000 0000
0 0 0000 0000
5 5 0000 0101
60 3C 0011 1100
110 6E 0110 1110
127 7F 0111 1111

The highest (leftmost) bit of all negative numbers equals one. It equals zero for positive numbers. Because of the sign, it’s impossible to store numbers greater than 127 in one byte. The minimum allowed negative number is -127 for the same reason.

There are two reasons why SMR is not widespread nowadays:

  1. Arithmetic operations on negative numbers complicate the processor architecture. A processor module for adding positive numbers is not suitable for negative numbers.

  2. There are two representations of zero: positive (0000 0000) and negative (1000 0000). This complicates the comparison operation because these values are not equal in memory.

It’s important that we get how SMR works. A good understanding of SMR will help us understand one’s and two’s complement, which are the two ways to represent integers.

Get hands-on with 1200+ tech skills courses.