[futurebasic] Re: Binary help (somewhat OT)

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

From: Caryn Roberts <caryn@...>
Date: Tue, 18 Nov 97 13:50:47 -0800
On 11/18/97 9:11 AM, Chris <behmc@...> said:

>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


It is just like subtraction in decimal.


Each digit has a "weight." In decimal it is powers of ten:

   1000s          100s           10s                1s
or 10 to the 3rd, 10 to the 2nd, 10 to the 1st, and 10 to the zero.

It goes on in each direction ad infinitum.

The same is true for all numbering systems, binary, octal, hexadecimal, 
base-12 and so on.



   32s           16s           8s            4s            2s             
or 2 to the 5th, 2 to the 4th, 2 to the 3rd, 2 to the 2nd, 2 to the 1st, 
and 2 to the zero.

So in the example above we have a "2 to the zero" subtracted from a null, 
so we have to borrow a
"2 to the 1st," or a value of two from the next digit, subtract the "2 to 
the 1st" (a one), leaving us with a value of 1 for the 2 to the zero 

We borrowed that 2 to the 1st digit so it is now zero.

We move to the left and find a zero in the 2 to the 2nd columns.

In the two to the 3rd column we subtract 0 from 1 leaving a one in that 
column in the result.

Move on to the 2 to the 4th column, subtract 1 from one, result is zero, 
and we're done.

The same principles apply to all numbering systems.

Caryn Roberts

visit me at: <http://www.halcyon.com/caryn/>