next up previous

Addition and subtraction of multi-bit numbers

In addition to evaluating propositions (predicates), we also want to be able to perform arithmetic. The basic operations one needs are addition and subtraction. With these we can clearly multiply and divide, and thereby calculate any function with a series expansion, or similar algorithm.

Numbers can be added in binary by using a cascade of operations where

$\displaystyle {\rm Result}$ = $\displaystyle A ~{\rm\bf XOR}~B$  
$\displaystyle {\rm Carry~forward}$ = $\displaystyle A ~{\rm\bf AND}~B.$ (8)

Subtraction is really just the addition of the complement, up to a carry bit (or modulo the radix of the numerical addition). This means that subtraction is `NOT addition mod 2'. We observe the same thing in denary:
6 - 2 = 4 (9)
6 + $\displaystyle (10-2) = 14 \rightarrow ({\rm mod}\; 10) = 4$ (10)



Mark Burgess
2000-10-22