Negation in the Binary System
 

Computers use a fixed number of "bits" or binary digits. An 8-bit number is 8 digits long. For this section, we will work with 8 bits.

Signed Magnitude:

The simplest way to indicate negation is signed magnitude. In signed magnitude, the left-most bit is not actually part of the number, but is just the equivalent of a +/- sign.



"0" indicates that the number is positive, "1" indicates negative. In 8 bits, 00001100 would be 12 (break this down into (1*2^3) + (1*2^2) ).

To indicate -12, we would simply put a "1" rather than a "0" as the first bit: 10001100.
One's Complement:

In one's complement, positive numbers are represented as usual in regular binary. However, negative numbers are represented differently.


To negate a number, replace all zeros with ones, and ones with zeros - flip the bits. Thus, 12 would be 00001100, and -12 would be 11110011. As in signed magnitude, the leftmost bit indicates the sign (1 is negative, 0 is positive).

To compute the value of a negative number, flip the bits and translate as before.
Two's Complement:

Begin with the number in one's complement. Add 1 if the number is negative. Twelve would be represented as 00001100, and -12 as 11110100. To verify this, let's subtract 1 from 11110110, to get 11110011. If we flip the bits, we get 00001100, or 12 in decimal.


In this notation, "m" indicates the total number of bits. For us (working with 8 bits), it would be excess 2^7. To represent a number (positive or negative) in excess 2^7, begin by taking the number in regular binary representation. Then add 2^7 (=128) to that number. For example, 7 would be 128 + 7=135, or 2^7+2^2+2^1+2^0, and, in binary,10000111. We would represent -7 as 128-7=121, and, in binary, 01111001.


Note:



  • Unless you know which representation has been used, you cannot figure out the value of a number.

  • A number in excess 2^(m-1) is the same as that number in two's complement with the leftmost bit flipped.

Using the regular algorithm for binary adition, add (5+12), (-5+12), (-12+-5), and (12+-12) in each system. Then convert back to decimal numbers.



Using the regular algorithm for binary adition, add (5+12), (-5+12), (-12+-5), and (12+-12) in each system. Then convert back to decimal numbers.
Signed Magnitude:

5+12 -5+12 -12+-5 12+-12

00000101 10000101 10001100 00001100
00001100 00001100 10000101 10001100
__________ ________ ________ _________
00010001 10010001 00010000 10011000

17 -17 16 -24

One' Complement:

00000101 11111010 11110011 00001100
00001100 00001100 11111010 11110011
_________ ________ ________ ________
00010001 00000110 11101101 11111111

17 6 -18 0

Two's Complement:

00000101 11111011 11110100 00001100
00001100 00001100 11111011 11110100
________ ________ ________ ________
00010001 00000111 11101111 00000000

17 7 -17 0

Signed Magnitude:

10000101 01111011 01110100 00001100
10001100 10001100 01111011 01110100
________ ________ ________ ________
00010001 00000111 11101111 01111100

109 119 111 124

(c) Shilpa Sayura Foundation 2006-2017