Binary Addition Machine

  • ... those who have a natural talent for calculation are generally quick-witted at every other kind of knowledge; and even the dull, if they have had an arithmetical training, although they may derive no other advantage from it, always become much quicker than they would have been. (Plato)

You will now construct your own binary addition machine. Check this one to start:

Building blocks:

1. First mouse click: Choose two random binary numbers number1 and number2 with digits number1[i] and number2[i]:

for (var i = 0; i < I-1; i++) {
number1[i] = floor(2*random());
number2[i] = floor(2*random());
}

2. Second mouse click: Add number1 to number2 digit by digit:

for (var i = 0; i<I-1; i++) {
sum[i]=number1[i] + number2[i];
}

3. Continued mouse clicks: Reduce to binary representation digit by digit:

if (sum[N]>1){
sum[N+1]=sum[N+1]+1;
sum[N]=sum[N]-2;
}

4. Activate mouse click:

function mousePressed(){
N=N+1;
}

Continue by checking this adding machine .