Integer numbers are whole numbers; they are always represented exactly (without a decimal point) in the computer word: -3, 0, 379, etc. For instance, 5 (decimal) is represented exactly by 101 (binary) in the computer. Since that's binary, the rightmost bit represents 2-to-the-zeroth power, or "one". Since it's "on" in this example, we have a value of "one". The next binary digit to the left represents 2 to the 1st power, or "two"; but it's off, so its value is zero. The leftmost bit represents 2 to the 2nd power, or "four". Since it's "on", we add four to the value. One plus four is five, which is why "101" in binary is "5" decimal... Exactly.

All positive, non-zero integer numbers are represented in this manner. There are differences in the way zero and negative numbers are represented, depending upon whether a ones complement , twos complement , or sign-magnitude system was implemented.



ONES COMPLEMENT

Negative X is obtained by inverting each bit of X; i.e.,

-X = not(X)

The leading bit of a number is the sign bit.  Positive numbers have a zero as the leading bit; negative numbers have a one as the leading bit.

One consequence of this is that there are two values for zero: +0 and -0.

For example, for a four-bit number (remember, the leading -- that is, leftmost -- bit is a sign bit):
 
Binary: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Decimal:  +0 +1 +2 +3 +4 +5 +6 +7 -7 -6 -5 -4 -3 -2 -1 -0



TWOS COMPLEMENT

Negative X is obtained by inverting each bit of X, and then adding one; i.e.,

-X = not(X)+1

The leading bit of a number is the sign bit.  Positive numbers have a zero as the leading bit; negative numbers have a one as the leading bit.

There is only one value for zero: all bits are zero (as opposed to the system used for One's Complement).

For example, for a four-bit number (remember, the leading -- that is, leftmost -- bit is a sign bit):
 
Binary: 0000 0001 0010 0011 0100 0101 0110 0111 1000
1001 1010 1011 1100 1101 1110 1111
Decimal:  0 +1 +2 +3 +4 +5 +6 +7 -8
-7 -6 -5 -4 -3 -2 -1

 Note that the range of negative numbers, and their values, are slightly different from one's complement.



SIGN-MAGNITUDE

This is the simplest way to represent negative numbers.  Numbers have the leading bit signify positive (0) or negative (1), while the following bits are the magnitude of the number.

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