Binary Signed Numbers

It’s time to introduce a new concept in numbers representation. Until now we have only dealt with unsigned numbers. But real numbers aren’t like that. They are signed, i.e. they can be positive or negative. And they must be represented like that in a manner that the computer can identify. The minus signal (-), for the computer is nothing more than a graphic corresponding to a 8 bit combination. Thus, it was agreed that the signal will be represented by the higher order bit. In a number of 8 bits, for instance, the signal will be represented by the bit of order 7, i.e.

X7 X6 X5 X4 X3 X2 X1 X0

X7 will be the signal in this number and it will assume the value 0 for positive numbers and 1 for negative numbers.
This way the number of bits used to represent the unsigned part of the number will be  less (7 in this case). So, the absolute maximum represented number’s value will be  smaller (128 instead of 256) although the range of represented numbers’s values were the same (-128 to +127 = 256 possible numbers).

From the several methods existing to represent a signed number the far most used is the two’s complement representation, the one we are going to deal with.

Two’s Complement Representation

In this representation method for 8 bits numbers:

  • The negative numbers  will be represented in its unsigned part decreasing from 11111111 (–1 decimal) to 10000000 (-128 decimal).
  • The positive numbers  will be represented in its unsigned part growing from 00000000 (0 decimal) to 01111111 (+127 decimal).
Figure-3-6
Figure 1

As we can see 0 is considered a positive number. This way, with 8 bits we will represent 128 negative numbers (-1 to -128) and 128 positive numbers (0 to +127).
The same goes for any Words with any number of bits, using an identical reasoning. We can see in the table of Figure 1, the range of decimal values which can be  represented by 4 bits, the highest order bit representing  the signal and the remaining 3 the unsigned part.

Thus, the binary numbers will always have their higher order bit representing its signal?

No, it’s not mandatorily like that. The meaning of the higher order bit will depend on the type of circuit it will be inserted in. It can be a representative bit for unsigned numbers or the signal for signed numbers. And the circuit will know how to interpret it.
An example of unsigned numbers are the addresses in memory for instance. The circuits for unsigned numbers are simpler. And when we are dealing with numbers that will ever be positive, like the addresses, representing them as unsigned gives us a bigger range of representation for the same number of bits.
With 32 bits for instance, with an unsigned number we can represent from 0 to 4,294,967,296 addresses and with a signed number from 0 to 2,147,483,648 as the negative range of representations doesn’t interest to us.
So, its up to us to decide how and when.

Returning to the two’s complement representation method, we are going to introduce another concept, the one of  a symmetrical of a binary number.

Symmetrical of a Binary Number

The symmetrical of a number is the number that added with it results in 0. That goes for decimal, for binary and for any base.  The symmetrical of a decimal number is obtained changing the sign we place before it from (-)  to (+) or vice versa.

And the symmetrical of a binary number? How can we get it?

The symmetrical of a binary number is calculated denying its bits and adding 1 to the result.

Deny its bits?

Deny the bits of a number is to convert each one of its bits in the opposite, one by one, 0 to 1 and 1 to 0.

And how does the computer manage with that?

This can be done applying the XOR operator to each one of the bits of a number together with a reference number with all its bits with the value 1. XOR is the difference operator. If the operands are different it returns 1 and if they are equal it returns 0. If the bit to deny is 1, thus equal to the reference bit 1, XOR returns 0. If the bit to deny is 0, thus different of the reference bit 1, XOR returns 1. As an example:

0110  XOR  1111 = 1001

Figure-3-8
Figure 2

Let’s calculate the symmetrical of +6 using this rule, and see how in the Table of  Figure 2. First we translate +6 to binary, what results in 0110, where 0 is the positive sign and 110 the positive binary representation of 6. Then we deny the bits of the result getting 1001.  Adding 0001 (1 em decimal) to the denied number we get  1010 where 1 is the negative sign and 010 the representation of negative 6, as we can see in Figure 1.

We’ve just gave an example for a 4 bits number contained inside the table of  Figure 1-6 which must be reviewed to understand positive and negative representations of the unsigned part of a number. From now on we will deal with 8 bits numbers in a two’s complement representation, where the highest order bit represents the signal and the remaining 7 the value of the unsigned part. Let’s n ow determine the symmetric of 55.
We will begin by converting the decimal 55 into binary.  In order to do this:

Converting Decimal into Binary

  • Figure-3-7
    Figure 3

    We divide 55 by 2. The remainder is the value of the lowest order bit.

  • Then we divide in succession the results of the division again by 2. The remainder of each division will be the value of the bit of the order above the previous division.
  • When we get to a result smaller than 2 this value will be the highest order representative bit.

 And here it is: 110111, the binary value of 55. The description of this conversion is exemplified in the graphic  of Figure 3.

But 110111 has only 6 bits and we’ve just said that from now on we wold work with 8 bits numbers.

Certainly we must choose another number!

Off course not. We are going to make the binary extension of a 6 bits number to 8 bits. Binary Extension, a new concept to introduce.

Binary Extension

In binary operations both operands must have the same number of bits. In opposition to what happens with our numbers, where the non significant values at left (like 0) are simply left empty, the bits shall always have its value 0 or 1 established. As we are dealing with circuits for 8 bits, all 8 bits must have established its value. Let’s prepare an 8 bits binary operation with 55 and 2.

The first one, 55, is represented by 6 bits. Its extension to 8 bits can be made with bits with value 0, as its value will remain the same

00110111

whre 00 is the extension and 110111 the number.
The second, 2, is represented by 2 bits. The same way its extension made with bits with value 0 will be

00000010

where 000000 is the extension and 10 the number.

Now  we can operate with them. But as you see we are doing this with unsigned numbers. And this is not our reality. We must see how we can do this extension in two’s complement representation. First we must put the signal in the numbers.

The binary representation of (+55) will be

0110111

where 0 is the sign and 110111 is the number.
The binary representation of (+2) will be:

010

where 0 is the sign and 10 the number.
For a new number, the (-2), it will be

110

where 1 is the sign and 10 is the number.

Wow! But we can’t extend negative numbers with 0, as that will change its value and even its signal!

Figure-3-10
Figura 4

Correct! For that reason in two’s complement representation the positive numbers are extended with 0 and the negative numbers are extended with 1, i.e. always with the highest order bit value, the signal.
In Figure 4 we exemplify with the extension of  2 and (-2) to 8 bits, where the bold digits are the signal, the blue enhanced digits are the number and the yellow enhanced digits the extension.

Figure-3-11
Figura 5

Now, once clarified the Binary Extension, we have the conditions to proceed with the calculation of 55 symmetrical value.

Figure-3-12
Figura 6

First thing is to make its extension to 8 bits, as we can see in Figure 5, where  the bold digits are the signal, the blue enhanced digits are the number and the yellow enhanced digits its extension.
The number 55 is now converted in binary and extended to 8 bits. It’s now time to deny the bits of its binary representation and add 1 to the result, as described in the table of Figure 6.

Figure-3-13Finally we add both to verify that the result is 0. The result will have 1 bit beneath the 8th which must be ignored. as we can see in Figure 7.

Why ignored?

An important question which will be taken in a large  paragraph further on, having to do with the Excess, i.e. the Carry Out of the last bit’s order, the 8th, in a binary operation.

For now we are going to follow with the subtraction.

6 thoughts on “Binary Signed Numbers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.