Custom Search

Binary: signed numbers (positive and negative)

When we input code into a computer we have to stick to binary input - high or low signals. We do not have a special signal for positive and negative. We have to enter a high or low.

To represent a positive binary number we make the MSB (most significant bit) low (a '0').

To represent a negative binary number we make the MSB high (a '1').

Sign-magnitude binary number format

In the 'olden days' that was all we did. Therefore 1101 was -5 and 0101 was +5. This led to problems with calculating values (that you do not have to worry about) and nowadays we use a method which seems a bit strange at first - but works out much better in practice. It is called complementation.

Two's Complement binary number format

Let us suppose the numbers are sent as 4-bit 'packets'.

The MSB is the sign therefore the 'number' part will vary from 000 to 111.

A zero in that MSB makes it easy to work out what the number is - it is just the binary value!

A one in that MSB represents a negative value for that column (in this case a -8). That has to be added to the binary number represented by the other columns.

For example 1011 is -8 +3 = -5

That means that positive numbers (ones with a zero in MSB) can go from zero to seven in decimal and the negative numbers go from -8 (the value of a '1' in that MSB) to -1.

Binary Notation Decimal Notation Binary Notation Decimal Notation
0000
0
1000
-8
0001
1
1001
-7
0010
2
1010
-6
0011
3
1011
-5
0100
4
1100
-4
0101
5
1101
-3
0110
6
1110
-2
0111
7
1111
-1

Because we are giving 'signs' to a binary number we reserve the MSB (most significant bit) for the purpose. That means that an eight bit register will only put 'number' values in the lower sever bits. It will therefore only be able to represent:

positive numbers up to 011111112 = 25510 and

negative numbers up to 100000002 = -25610

In general if a binary number has N digits:

the most negative value you can represent is the value of the MSB digit - 2N-1, and

the most positive number you can represent is that digit value -1 = 2N-1-1

For example:

A six digit binary number would have a MSB of value 26-1 = 25 = 32.

In two's complement format the most negative value will be:

100000 (-32 in decimal)

and the most positive value will be

011111 (31 in decimal).

See here for more detail on two's complement.

Short-cut way of determining the negative value:

When dealing with only 4 or 5 bit notation it is not difficult to work out the negative value; but when dealing with more bits it can be laborious.

There is a very easy way to do it :) Click here to find out how!