Stupid question that's been annoying me

From: Gordon Zaft <zaft_at_azstarnet.com>
Date: Sun Sep 30 00:56:01 2001

         You do realize that in signed arithmetic anything with the leading
bit set is a negative number?

At 11:32 PM 9/29/2001 -0500, you wrote:
>Yes, I'm actually going to ask a question about two's complement
>arithmetic! I feel quite stupid for mailing this, but I just can't figure
>it out. And believe it or not, it really does have something to do with
>classic computing. All right, here goes...
>
>While I was in class Thursday, I got bored and decided to pass the time by
>verifying that A-B=A+(-B) in two's complement binary arithmetic, using an
>imaginary machine with a word size of 2 bits. I created the following
>table:
>
>Subtraction Equivalent Addition
>AA-BB=CC CZSV AA+BB=CC CZSV
>01 01 00 .x.. 01 11 00 xx..
>01 00 01 .... 01 00 01 ....
>01 11 10 x.xx 01 01 10 ..xx
>01 10 11 x.xx 01 10 11 ..x.
>00 01 11 x.x. 00 11 11 ..x.
>00 00 00 .x.. 00 00 00 .x..
>00 11 01 x... 00 01 01 ....
>00 10 10 x.xx 00 10 10 ..x.
>11 01 10 ..x. 11 11 10 x.x.
>11 00 11 ..x. 11 00 11 ..x.
>11 11 00 .x.. 11 01 00 xx..
>11 10 01 .... 11 10 01 x..x
>10 01 01 ...x 10 11 01 x..x
>10 00 10 ..x. 10 00 10 ..x.
>10 11 11 x.x. 10 01 11 ..x.
>10 10 00 .x.. 10 10 00 xx.x
>
>The left half iterates through all possible subtractions, which were each
>performed by hand by binary subtraction. The results and the states of
>the machine's flags (Carry/borrow, Zero, Sign, oVerflow), are shown.
>
>The right half contains the same subtractions, this time done by adding by
>hand the minuend and the two's complement of the subtrahend.
>
>Note that the C and V flags behave differently in each half. This is very
>disturbing, since I'm fairly certain that subtraction is implemented in
>many processors as adding a negated subtrahend (ergo, I should see no
>difference in the flags). What have I done wrong in my table?
>
>--
>Jeffrey S. Sharp
>jss_at_subatomix.com
Received on Sun Sep 30 2001 - 00:56:01 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:26 BST