[futurebasic] Re: Binary help (somewhat OT)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: Jason Conkey <jconkey@...>
Date: Tue, 18 Nov 1997 12:23:13 -0800
If you need negative numbers, then a good way to represent numbers is
two's-complement notation.  Basically, the high bit is the sign bit, where
a 1 means the number is negative.  To add two numbers, simply do the normal
binary addition.  To subtract, take the two's complement of the number you
are subtracting and then add it to the other number.

For example, to do this operation:  A-B
Take the two's complement of B, and add it to A.

To get the two's complement, invert each bit and add 1.

I don't enough time right now for more examples, but maybe later I can tell
more.  Sorry.

HTH,
Jason


>>>>>Can someone give me the basics of binary addition and subtraction?  I
>>>>>think
>>>>>I understand (and can do) binary addition, but subtraction is giving me
>>>>>fits.
>>>>>
>>>>>Thanks,
>>>>>*Chris
>>>>