Binary Arithmetic

Signed Binary Numbers

Sign and Magnitude

Where do you put the sign bit?

Is the leftmost or the rightmost bit better?

We need an extra step to determine the sign of the result of an addition. Why?

Both positive and negative zero exist in this representation. What does this mean for the programmer?

Two's Complement

Form negative numbers by taking the complement (apply the not operator) of the corresponding positive number and adding one.

Eight bit two's complement binary numbers:

-4ten = not 00000100 + 1two = 11111011 + 1two = 11111100two

-128ten = not 10000000 + 1two = 01111111 + 1two = 10000000two

128ten cannot be represented as an eight bit two's complement binary number!

The leftmost bit is the sign bit. If it is one, the number is negative and its decimal value can be found by taking the complement and adding one. This is equivalent to subtracting one and then taking the complement.

Eight bit two's complement binary numbers:

00001000two = 8ten

10001000two = not 10001000 + 1two = 01110111 + 1two = 01111000two = -120ten


CSE 378 Spring 2002 - Section 1
First Previous Page 3 Next Last