Binary Addition Machine

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 .