-
Notifications
You must be signed in to change notification settings - Fork 0
/
binary_finger_abacus-more_examples.txt
704 lines (610 loc) · 35.7 KB
/
binary_finger_abacus-more_examples.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
Examples of the binary abacus functions:
The following 3 examples show a special case of binary multiplication.
Similar to how 10 dec shifts any number it is multiplied by to the left one column.
Binary works much the same way except that the values of 10, 100, 1000 are binary and so 2, 4, 8 etc.
365x2 = 730
1:
----- ----1 : 365 is odd. All odd numbers will have a 1 in the first column. Subtract one from 365 ( 364 ) and divide by 2 ( 182 ) to get the
number for next position.
----- ---01 : 182 is even so leave a 0 in the remainder trail. Do not subtract from even numbers and divide by 2 ( 91 ).
----- --101 : 91 is odd so subtract 1 ( 90 ), then half the number ( 45 ).
----- -1101 : 45 is odd so -1 ( 44 ) and half ( 22 ).
----- 01101 : 22 is even so half ( 11 ).
----1 01101 : 11 is odd so -1 ( 10 ) and half ( 5 ).
---11 01101 : 5 is odd so -1 ( 4 ) and half ( 2 ).
--011 01101 : 2 is even so half ( 1 ).
-1011 01101 : 1 is odd and the last number, so we are done with converting 365.
2 is 10 in binary. So the multiplication will overlay 10 at every positive bit in the binary number just created. This has the effect of shifting the whole number over one column left.
This could be done step by step but is much simpler to think of as a single operation as you go from left to right shifting
as you go leaving a 0 in the rightmost column (every number doubled is even ). So you get:
10110 11010 : 512 + 0 + 128 + 64 + 0 + 16 + 8 + 0 + 2 + 0 = 730 ( Note that in any group of binary digits 1010 the sum is 10 times the value of the least significant digit. )
This can be converted back on the abacus like so:
1*0110 11010 : Starting at the most significant bit take its value of 1 and next is to move to the right and double it.
10*110 11010 : At this step the value is 2 since as we moved right we doubled.
101*10 11010 : At this step we double then add 1 since this bit is positive. 4 + 1 = 5.
1011*0 11010 : This step we double and add 1. 10 + 1 = 11.
10110* 11010 : Double and add 0. 22.
10110 1*1010 : Double and add 1 for positive bit. 44 + 1 = 45.
10110 11*010 : Double and add 1. 90 + 1 = 91.
10110 110*10 : Double. 182.
10110 1101*0 : Double and add 1. 364 + 1 = 365.
10110 11010* : Double. 730.
128x4 = 512
2:
----- ----0 : 128 is even so the first column is even. divide by 2 to get 64.
----- ---00 : 64 is even, divide by 2 to get 32
----- --000 : 32 is even, 32/2 = 16
----- -0000 : 16 is even, 16/2 = 8
----- 00000 : 8 is even, 8/2 = 4
----0 00000 : 4 is even, 4/2 = 2
---00 00000 : 2 is even, 2/2 = 1
--100 00000 : 1 is odd and the end of the conversion.
Since 128 is a power of 2 is only has 1 positive bit set, like powers of 10 in decimal. Similarly to the multiply by 2 example above, in this example we could apply shifting
and move the bit over 2 spaces. 1 space for each 0 in binary 4 ( 100 ), Alternatively we could shift 4 over the 7 zeros from 128 and get the same answer, or using the abacus method this is very simple too by just placing the 100 at the position of the one in 128. Using any of those methods the answer is:
10000 00000 : 512 + 0 + 0 ... etc. = 512.
Using the abacus conversion is essentially:
1 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 512
45X8 = 360
3:
----- ----1 : 45 is odd so the first bit is one. All odd numbers will have 1 in the first column. To get the next columns number subtract 1 and divide by 2. (45-1)/2 = 22.
----- ---01 : 22 is even so the next bit is 0. Divide by 2 to get 11, the number for the next column.
----- --101 : 11 is odd so the next bit is 1. Subtract 1 and divide by 2. (11-1)/2=5.
----- -1101 : 5 is odd so next bit is 1. (5-1)/2=2.
----- 01101 : 2 is even so bit is 0. 2/2=1.
----1 01101 : 1 is odd and the end of the conversion, so the last bit is 1.
Like the previous 2 power of 2 examples, we can just shift the bits over 3 spaces this time, since 8 in binary is 1000. So that becomes:
-1011 01000 : Which is 256 + 0 + 64 + 32 + 0 + 8 + 0 + 0 + 0 = 360. Also using the 1010 pattern describes above You can extract 320 + 40 = 360.
Using the abacus conversion would be:
( ( ( ( ( ( 1 * 2 * 2 ) + 1 ) * 2 ) + 1 ) * 2 * 2 ) + 1 ) * 2 * 2 * 2 = 360
That looks more complicated than the last one because it is all written as one operation, but when done step by step with the abacus rules it isn't much more complicated than the last example.
-1*011 01000 : Start with focus on the first bit on the left we begin with a count of 0 and add for the first bit, making the count 1.
-10*11 01000 : Moving focus right first double the count, then add the bit value of the column: ( 1 * 2 ) + 0 = 2
-101*1 01000 : Move focus, double and add bit value. ( 2 * 2 ) + 1 = 5
-1011* 01000 : ( 5 * 2 ) + 1 = 11
-1011 0*1000 : ( 11 * 2 ) + 0 = 22
-1011 01*000 : ( 22 * 2 ) + 1 = 45
-1011 010*00 : ( 45 * 2 ) + 0 = 90
-1011 0100*0 : ( 90 * 2 ) + 0 = 180
-1011 01000* : ( 180 * 2 ) + 0 = 360
16x9 = 144 ( 1 Gross, 16 is 4^2 and 9 is 3^2 and they can refactor to 12^2 )
4:
So this one is actually another power of 2 example, but now with 4 0s since 16 in binary is 10000. For this case it may be easiest to address this directly with the abacus method and
start with the larger number in the abacus and place the 9 at it's one positive bit.
----- 1*0000 : Start with 16 on the abacus and focus on the most significant bit.
----- 1*0000 : When doing abacus multiplication you replace each positive bit with the multiplicand. 9 is odd so the replacement is a 1 for the first bit, also subtract 1 and divide by 2 to get the next number. ( 9 - 1 )/2 = 4.
----0 1*0000 : 4 is even so place a 0 at the next position as we place nine. 4/2 = 2.
---00 1*0000 : 2 is even so place another 0. 2/2=1
--100 1*0000 : 1 is odd and the end of converting 9. This places a 9 at the 16 bit and completes our multiplication because no other bits are positive.
Now to convert the answer to decimal:
--1*00 10000 : Count is 1.
--10*0 10000 : ( 1 * 2 ) + 0 = 2
--100* 10000 : ( 2 * 2 ) + 0 = 4
--100 1*0000 : ( 4 * 2 ) + 1 = 9 - As we reach the last of the positive bits the value is the same as the multiplicand.
--100 10*000 : ( 9 * 2 ) + 0 = 18
--100 100*00 : ( 18 * 2 ) + 0 = 36
--100 1000*0 : ( 36 * 2 ) + 0 = 72
--100 10000* : ( 72 * 2 ) + 0 = 144
12X12 = 144
5:
----- ----0 : 12 is even put 0 in bit column, 12/2=6
----- ---00 : 6/2 = 3
----- --100 : 3 is odd so 1 in bit column. (3-1)/2=1
----- -1100 : 1 is odd and end of conversion.
Now we will apply the conversion of 12 at each 1 bit.
----- -1*100 : Start with focus on the largest positive bit, aka the most significant bit.
---11 00*100 : With this first bit the multiplicand just replaces the first bit, in this case with 1100 which our previous conversion showed as 12.
---11 001*00 : Now move focus to the next positive bit in the original number and apply the 12 conversion there.
---11 00.0*00 : The . will represent the bit of the conversion being applied this step. In this first step the 1 bit is replaced by the least significant bit of the converted number. 0 in this case.
---11 0.00*00 : The next bit of 12 as 1100 is applied. Another 0. Only the first bit is a replacement, the rest are added. 0 + 0 = 0
---11 .100*00 : The next bit is applied and it is a 1. It is applied to a position with a 0. 0 + 1 = 1. So the position now has a 1 but does not carry.
--10.0 100*00 : The next applied bit is a 1. It is applied to a position with a 1, 1 + 1 = 10 ( aka 2 ) so there is a carry. And that position carries as well so in total it carries 2 positions. That is the last bit of the conversion. And the last positive bit of the original number, so the multiplication is complete.
And we have our answer --100 10000, which is the same as the last example and equals 144.
14X21=294
6:
----- ----1 : 21 is odd. (21-1)/2 = 10
----- ---01 : 10 is even. (10-0)/2=5
----- --101 : 5 is odd. (5-1)/2=2
----- -0101 : 2 is even. (2-0)/2=1
----- 10101 : 1 is odd and ends conversion.
----- 1*0101 : Focus here to begin multiplication.
----- .0*0101 : Replace first bit. 14 is even so first replacement is 0. (14-0)/2=7
----.1 0*0101 : 7 is odd add 1 to next column. 0+1=1. (7-1)/2=3
---.11 0*0101 : 3 is odd add 1 to next column. (3-1)/2=1
--.111 0*0101 : 1 is odd and ends the conversion at that bit. We now know that 1110 is the conversion for 14.
--111 001*01 : Move focus to next positive bit to the right in the original 21.
--111 00.0*01 : Replace first bit with least significant bit from multiplicand. 0 in this case.
--111 0.10*01 : At the next column we add in the values from the multiplicand, 0+1=1
--111 .110*01 : Adding again, 0+1=1, no carry.
-100.0 110*01 : Adding again, 1+1=10 (2), this carries for 3 columns, end of this conversion.
-1000 11001* : Move focus to last positive bit of original 21.
-1000 1100.0* : Replace first bit.
-1000 110.10* : Add to next bit. 0+1=1
-1000 11.110* : Add again. 0+1=1
-1001 0.0110* : Add again. 1+1=10(2). Carries 2 columns to the next 0. Conversion complete and multiplication complete.
-1001 00110 : Is our answer, not to convert to decimal.
-1*001 00110 : Count is at 1.
-10*01 00110 : Count is (1*2)+0 = 2
-100*1 00110 : Count is (2*2)+0 = 4
-1001* 00110 : Count is (4*2)+1 = 9
-1001 0*0110 : Count is (9*2)+0 = 18
-1001 00*110 : Count is (18*2)+0 = 36
-1001 001*10 : Count is (36*2)+1 = 73
-1001 0011*0 : Count is (73*2)+1 = 147
-1001 00110* : Count is (147*2)+0 = 294
6*10=60
----- ----0 : Converting 10, it is even so first bit is 0. (10-0)/2=5
----- ---10 : 5 is odd. (5-(5%2))/2=2 ( Got fancy here since that is how I would program this step. The modulus(remainder) of the current number divided by 2 is one way to get what we subtract )
----- --010 : 2 is even. 2/2=1
----- -1010 : 1 is odd and the end of conversion to 10.
----- -1*010 : adding focus for multiplication.
----- -.0*010 : Making replacement of first bit as we convert 6. 6 is even so it's first bit ( least significant bit ) is 0. 6/2=3
----- .10*010 : Add in next bit, 3 is odd so it is a 1. (3-1)/2=1
----.1 10*010 : Add in next bit. 1 is odd and the end of this conversion.
----1 1001*0 : Move focus to the next positive bit and begin conversion/replacement/add-in of 6.
----1 100.0*0 : Replace with the first bit.
----1 10.10*0 : Add in the second bit, 0+1=1, no carry.
----1 1.110*0 : Add in next bit, no carry and done. This is our answer.
----1 11100 : Answer without markers. Lets convert:
----1* 11100 : Count is 1.
----1 1*1100 : Count is (1*2)+1=3
----1 11*100 : Count is (3*2)+1=7
----1 111*00 : Count is (7*2)+1=15
----1 1110*0 : Count is (15*2)+0=30
----1 11100* : Count is (30*2)+0=60
Subtraction:
15 - 9 = 6
----- ----1 : 15 is odd, (15-1)/2=7
----- ---11 : 7 is odd, (7-1)/2=3
----- --111 : 3 is odd, (3-1)/2=1
----- -1111 : 1 is odd, end of conversion, now to overlay and subtract.
----- -111*0 : 9 is odd so we subtract 1 from the first bit, 1-1=0, so the first bit is 0, no borrow. And converting 9, (9-1)/2=4
----- -11*10 : 4 is even so we subtract 0 from the next bit, 1-0=1, so the next bit remains 1, no borrow. And converting 9, 4/2=2
----- -1*110 : 2 is even, so subtract 0 again and again the bit remains 1. And converting 9, 2/2=1
----- -*0110 : 1 is odd, so we subtract 1 from the last bit. 1-1=0. The conversion is done and we have our answer. Dropping all leading zeros we have 110 or 6
954-339 =
----- ----0 : 954 is even, (954-0)/2=477
----- ---10 : 477 is odd, (477-1)/2=238
----- --010 : 238 is even, (238-0)/2=119
----- -1010 : 119 is odd, (119-1)/2=59
----- 11010 : 59 is odd, (59-1)/2=29
----1 11010 : 29 is odd, (29-1)/2=14
---01 11010 : 14 is even, (14-0)/2=7
--101 11010 : 7 is odd, (7-1)/2=3
-1101 11010 : 3 is odd,(3-1)/2=1
11101 11010 : 1 is odd and ends conversion of 954.
11101 1101*0 : return focus to the least significant bit,
11101 1100*1 : 339 is odd, 0-1=1 with borrow, so there is a borrow from the next bit up which has a 1. (339-1)/2=169
11101 110*01 : move focus to next bit.
11101 101*11 : 169 is odd, 0-1=1 with borrow, borrow carries over 2columns to the next positive bit (set to one). (169-1)/2=84
11101 10*111 : move focus to next bit in conversion.
11101 10*111 : 84 is even, 1-0=1, bit remains unchanged. (84-0)/2=42
11101 1*0111 : move focus to next bit in conversion
11101 1*0111 : 42 is even, 0-0=0,bit is unchanged. (42-0)/2=21
11101 *10111 : move focus to next bit
11101 *00111 : 21 is odd, 1-1=0, bit is now 0, no borrow. (21-1)/2=10
1110*1 00111 : 10 is even, 1-0=1, no change. (10-0)/2=5
111*01 00111 : move focus
110*11 00111 : 5 is odd, 0-1=1 with borrow. Only borrow for one column to the next 1. (5-1)/2=2
11*011 00111 : move focus
11*011 00111 : 2 is even,0-0=0, no change. 2/2=1
1*1011 00111 : move focus
1*0011 00111 : 1 is odd, 1-1=0, bit is 0, no borrow. 1 is the end of the conversion and the subtraction is done
10011 00111 : This is our answer, now to convert back to decimal.
1*0011 00111 : Count is 1.
10*011 00111 : Count is (1*2)+0=2.
100*11 00111 : Count is (2*2)+0=4.
1001*1 00111 : Count is (4*2)+1=9.
10011* 00111 : Count is (9*2)+1=19.
10011 0*0111 : Count is (19*2)+0=38.
10011 00*111 : Count is (38*2)+0=76.
10011 001*11 : Count is (76*2)+1=153.
10011 0011*1 : Count is (153*2)+1=307.
10011 00111* : Count is (307*2)+1=615.
23-12=
----- ----1 : 23 is odd, (23-1)/2=11
----- ---11 : 11 is odd, (11-1)/2=5
----- --111 : 5 is odd, (5-1)/2=2
----- -0111 : 2 is even, (2-0)/2=1
----- 10111 : 1 is odd, and the end of the conversion of 23
----- 1011*1 : move focus to first bit
----- 1011*1 : 12 is even, 1-0=1, no change. (12-0)/2=6
----- 101*11 : move focus
----- 101*11 : 6 is even, no change. (6-0)/2=3
----- 10*111 : move focus
----- 10*011 : 3 is odd, 1-1=0, no borrow. (3-1)/2=1
----- 1*0011 : move focus
----- 0*1011 : 1 is odd. 0-1=1 with borrow. Borrows from next bit up. 1 is the end of the conversion.
----- -1011 : This is the answer. Now to convert.
----- -1*011 : Count is 1
----- -10*11 : Count is (1*2)+0=2
----- -101*1 : Count is (2*2)+1=5
----- -1011* : Count is (5*2)+1=11
333-90=
----- ----1 : 333 is odd, (333-1)/2=166
----- ---01 : 166 is even, (166-0)/2=83
----- --101 : 83 is odd, (83-1)/2=41
----- -1101 : 41 is odd, (41-1)/2=20
----- 01101 : 20 is even, (20-0)/2=10
----0 01101 : 10 is even, (10-0)/2=5
---10 01101 : 5 is odd, (5-1)/2=2
--010 01101 : 2 is even, (2-0)/2=1
-1010 01101 : 1 is odd and the end of the conversion of 333.
-1010 0110*1 : move focus to first bit
-1010 0110*1 : 90 is even, no change. (90-0)/2=45
-1010 011*01 : move focus to next bit
-1010 010*11 : 45 is odd, 0-1=1 with borrow. Borrow from next column. (45-1)/2=22
-1010 01*011 : move focus to next bit
-1010 01*011 : 22 is even, 0-0=0, no change. (22-0)/2=11
-1010 0*1011 : move focus to next bit
-1010 0*0011 : 11 is odd, 1-1=0, no borrow. (11-1)/2=5
-1010 *00011 : move focus to next bit
-1001 *10011 : 5 is odd, 0-1=1 with borrow. Borrow from next 2 columns. (5-1)/2=2
-100*1 10011 : move focus to next bit
-100*1 10011 : 2 is even, 0-0=0, no change. (2-0)/2=1
-10*01 10011 : move focus to next bit
-01*11 10011 : 1 is odd, 0-1=1 with borrow. Borrow from next 2 columns. 1 is the end of the conversion and this is our answer.
--111 10011 : Now to convert back to decimal.
--1*11 10011 : Count is 1.
--11*1 10011 : Count is (1*2)+1=3.
--111* 10011 : Count is (3*2)+1=7.
--111 1*0011 : Count is (7*2)+1=15.
--111 10*011 : Count is (15*2)+0=30.
--111 100*11 : Count is (30*2)+0=60.
--111 1001*1 : Count is (60*2)+1=121.
--111 10011* : Count is (121*2)+1=243.
789-45=
----- ----1 : 789 is odd, (789-1)/2=394
----- ---01 : 394 is even, (394-0)/2=197
----- --101 : 197 is odd, (197-1)/2=98
----- -0101 : 98 is even, (98-0)/2=49
----- 10101 : 49 is odd, (49-1)/2=24
----0 10101 : 24 is even, (24-0)/2=12
---00 10101 : 12 is even, (12-0)/2=6
--000 10101 : 6 is even, (6-0)/2=3
-1000 10101 : 6 is odd, (3-1)/2=1
11000 10101 : 1 is odd and the end of converting 789.
11000 1010*1 : move focus to first bit
11000 1010*0 : 45 is odd, 1-1=0 with no borrow. (45-1)/2=22
11000 101*00 : move focus to next bit
11000 101*00 : 22 is even, 0-0=0 no change. (22-0)/2=11
11000 10*100 : move focus to next bit
11000 10*000 : 11 is odd, 1-1=0 with no borrow. (11-1)/2=5
11000 1*0000 : move focus to next bit
11000 0*1000 : 5 is odd, 0-1=1 with borrow. (5-1)/2=2
11000 *01000 : move focus to next bit
11000 *01000 : 2 is even, 0-0=0 no change. (2-0)/2=1
1100*0 01000 : move focus to next bit
1011*1 01000 : 1 is odd, 0-1=1 with borrow. Borrow from next 3 columns. Flip all bits to the next 1. 1 is the end of the conversion and this is our answer.
10111 01000 : The answer, not to convert back.
1*0111 01000 : Count is 1.
10*111 01000 : Count is (1*2)+0=2.
101*11 01000 : Count is (2*2)+1=5.
1011*1 01000 : Count is (5*2)+1=11.
10111* 01000 : Count is (11*2)+1=23.
10111 0*1000 : Count is (23*2)+0=46.
10111 01*000 : Count is (46*2)+1=93.
10111 010*00 : Count is (93*2)+0=186.
10111 0100*0 : Count is (186*2)+0=372.
10111 01000* : Count is (372*2)+0=744.
Addition:
11 + 11=
----- ----1: 11 is odd, (11-1)/2=5
----- ---11: 5 is odd, (5-1)/2=2
----- --011: 2 is even, (2-0)/2=1
----- -1011: 1 is odd and the end of converting 11.
----- -1011*: move focus back to the first bit
----- -1100*: 11 is odd, 1+1=0 with carry for two columns. (11-1)/2=5
----- -110*0: move focus to next bit
----- -111*0: 5 is odd, 0+1=1 with no carry. (5-1)/2=2
----- -11*10: 2 is even, 1+0=1 with no carry, so no change. (2-0)/2=1
----- -1*110: move focus to next bit
----- 10*110: 1 is odd, 1+1=0 with carry. 1 is the end of the conversion and this is the answer.
----- 10110 : Our answer, now to convert back to decimal.
----- 1*0110 : Count is 1.
----- 10*110 : Count is (1*2)+0=2.
----- 101*10 : Count is (2*2)+1=5.
----- 1011*0 : Count is (5*2)+1=11.
----- 10110* : Count is (11*2)+0=22.
16+23=
----- 10000 : Start with 16 on the abacus
----- 10000* : move focus to first bit
----- 10001* : 23 is odd, 0+1=1 no carry. (23-1)/2=11
----- 1000*1 : move focus to next bit
----- 1001*1 : 11 is odd, 0+1=1 no carry. (11-1)/2=5
----- 100*11 : move focus to next bit
----- 101*11 : 5 is odd, 0+1=1 no carry. (5-1)/2=2
----- 10*111 : move focus to next bit
----- 10*111 : 2 is even, 0+0=0, no change. (2-0)/2=1
----- 1*0111 : move focus to next bit. All of these bits are really zero.
----1 0*0111 : 1 is odd, 1+1=0 with carry. 1 is the end of the conversion and this is the answer.
----1 00111: Our answer. Now to convert back.
----1* 00111 : Count is 1.
----1 0*0111 : Count is (1*2)+0=2.
----1 00*111 : Count is (2*2)+0=4.
----1 001*11 : Count is (4*2)+1=9.
----1 0011*1 : Count is (9*2)+1=19.
----1 00111* : Count is (19*2)+1=39.
45 + 166
----- ----1 : 45 is odd, (45-1)/2=22
----- ---01 : 22 is even, (22-0)/2=11
----- --101 : 11 is odd, (11-1)/2=5
----- -1101 : 5 is odd, (5-1)/2=2
----- 01101 : 2 is even, (2-0)/2=1
----1 01101 : 1 is odd and the end of converting 45.
----1 01101* : move focus back to the first bit
----1 01101* : 166 is even, 1+0=1 no carry. (166-0)/2=83
----1 0111*1 : 83 is odd, 0+1=1 no carry. (83-1)/2=41
----1 100*11 : 41 is odd, 1+1=0 with carry. Carry for 2 columns. (41-1)/2=20
----1 10*011 : 20 is even, 0+0=0 with no carry. (20-0)/2=10
----1 1*0011 : 10 is even, 1+0=1 with no carry. (10-0)/2=5
---10* 10011 : 5 is odd, 1+1=0 with carry. (5-1)/2=2
---1*0 10011 : 2 is even, 1+0=1 no carry. (2-0)/2=1
--1*10 10011 : 1 is odd, 0+1=1 no carry. 1 is the end of the conversion. And this is our answer.
--110 10011 : Our answer, now to convert back.
--1*10 10011 : Count is 1.
--11*0 10011 : Count is (1*2)+1=3.
--110* 10011 : Count is (3*2)+0=6.
--110 1*0011 : Count is (6*2)+1=13.
--110 10*011 : Count is (13*2)+0=26.
--110 100*11 : Count is (26*2)+0=52.
--110 1001*1 : Count is (52*2)+1=105.
--110 10011* : Count is (105*2)+1=211.
222+63
----- ----0 : 222 is even, (222-0)/2=111
----- ---10 : 111 is odd, (111-1)/2=55
----- --110 : 55 is odd, (55-1)/2=27
----- -1110 : 27 is odd, (27-1)/2=13
----- 11110 : 13 is odd, (13-1)/2=6
----0 11110 : 6 is even, (6-0)/2=3
---10 11110 : 3 is odd, (3-0)/2=1
--110 11110 : 1 is odd and the end of converting 222.
--110 11110* : move focus back to the first bit
--110 11111* : 63 is odd, 0+1=1 no carry. (63-1)/2=31
--111 0000*1 : 31 is odd, 1+1=0 with carry four columns. (31-1)/2=15
--111 001*01 : 15 is odd, 0+1=1 no carry. (15-1)/2=7
--111 01*101 : 7 is odd, 0+1=1 no carry. (7-1)/2=3
--111 1*1101 : 3 is odd, 0+1=1 no carry. (3-1)/2=1
-1000* 11101 : 1 is odd, 1+1=0 with carry 2 columns. 1 is the end of the conversion. And this is our answer.
-1000 11101 : Our answer. Now to convert to decimal.
-1*000 11101 : Count is 1
-10*00 11101 : Count is (1*2)+0=2
-100*0 11101 : Count is (2*2)+0=4
-1000* 11101 : Count is (4*2)+0=8
-1000 1*1101 : Count is (8*2)+1=17
-1000 11*101 : Count is (17*2)+1=35
-1000 111*01 : Count is (35*2)+1=71
-1000 1110*1 : Count is (71*2)+0=142
-1000 11101* : Count is (142*2)+1=285
134+887
----- ----0 : 134 is even, (134-0)/2=67
----- ---10 : 67 is odd, (67-1)/2=33
----- --110 : 33 is odd, (33-1)/2=16
----- -0110 : 16 is even, (16-0)/2=8
----- 00110 : 8 is even, (8-0)/2=4
----0 00110 : 4 is even, (4-0)/2=2
---00 00110 : 2 is even, (2-0)/2=1
--100 00110 : 1 is odd and the end of converting 134
--100 00110* : move focus back to the first bit
--100 00111* : 887 is odd, 0+1=1 no carry. (887-1)/2=443
--100 0011*1 : move focus to the next bit
--100 0100*1 : 443 is odd, 1+1=0 with carry for 2 columns. (443-1)/2=221
--100 010*01 : move focus to the next bit
--100 011*01 : 221 is odd, 0+1=1 no carry. (221-1)/2=110
--100 01*101 : move focus to the next bit
--100 01*101 : 110 is even, 1+0=1 no carry. (110-0)/2=55
--100 0*1101 : move focus to the next bit
--100 1*1101 : 55 is odd, 0+1=1 no carry. (55-1)/2=27
--100* 11101 : move focus to the next bit
--101* 11101 : 27 is odd, 0+1=1 no carry. (27-1)/2=13
--10*1 11101 : move focus to the next bit
--11*1 11101 : 13 is odd, 0+1=1 no carry. (13-1)/2=6
--1*11 11101 : move focus to the next bit
--1*11 11101 : 6 is even, 1+0=1 no carry. (6-0)/2=3
--*111 11101 : move focus to the next bit
-1*111 11101 : 3 is odd, 0+1=1 no carry. (3-1)/2=1
-*1111 11101 : move focus to the next bit
1*1111 11101 : 1 is odd, 0+1=1 no carry. 1 is the end of the conversion. And this is our answer.
11111 11101 : Our answer, now to convert back to decimal.
1*1111 11101 : Count is 1
11*111 11101 : Count is (1*2)+1=3
111*11 11101 : Count is (3*2)+1=7
1111*1 11101 : Count is (7*2)+1=15
11111* 11101 : Count is (15*2)+1=31
11111 1*1101 : Count is (31*2)+1=63
11111 11*101 : Count is (63*2)+1=127
11111 111*01 : Count is (127*2)+1=255
11111 1110*1 : Count is (255*2)+0=510
11111 11101* : Count is (510*2)+1=1021
Division:
985/34
----- ----1 : 985 is odd, (985-1)/2=492
----- ---01 : 492 is even, (492-0)/2=246
----- --001 : 246 is even, (246-0)/2=123
----- -1001 : 123 is odd, (123-1)/2=61
----- 11001 : 61 is odd, (61-1)/2=30
----0 11001 : 30 is even, (30-0)/2=15
---10 11001 : 15 is odd, (15-1)/2=7
--110 11001 : 7 is odd, (7-1)/2=3
-1110 11001 : 3 is odd, (3-1)/2=1
11110 11001 : 1 is odd. 1 is the end of the conversion of 985
Sometimes with small divisors it is easiest to subtract from the most significant bits as you can easily keep their length in mind. 34 is large enough that in this example we could
subtract from the least significant bits for the "find remainder" step. That will lead to more steps, in this case a lot more steps. Another option is to estimate the length and
subtract from that point. So 34 is between the 64 bit and the 32 bit in value, so it's length will be the the length of the 32 bit column or 6 bits. This can determined by
counting bit columns ( 1, 2, 4, 8 ... ) on your knuckles to find position to subtract at.
11110 1*1001 : Move focus to the sixth bit from the end.
11110 1*1001 : 34 is even. 1-0=1 no borrow. (34-0)/2=17
11110* 11001 : Move focus to next bit up.
11101* 11001 : 17 is odd, 0-1=1 with borrow. (17-1)/2=8
1110*1 11001 : Move focus to next bit.
1110*1 11001 : 8 is even, 0-0=0 no borrow. (8-0)/2=4
111*01 11001 : Move focus to next bit.
111*01 11001 : 4 is even, 1-0=1 no borrow. (4-0)/2=2
11*101 11001 : Move focus to next bit.
11*101 11001 : 2 is even, 1-0=1 no borrow. (2-0)/2=1
1*1101 11001 : Move focus to next bit.
0*1101 11001 : 1 is odd, 1-1=0, no borrow. We've completed a subtraction pass and subtracted 34 * 16(because the number started offset by 4 bits from the least significant position just as a decimal number offset by 4 positions would be multiplied by 10,000) from 985.
01101 11*001 : Move focus to sixth bit from the left again.
01101 11*001 : 34 is even. 1-0=1 no borrow. (34-0)/2=17
01101 1*1001 : Move focus to next bit up.
01101 0*1001 : 17 is odd, 1-1=0 with no borrow. (17-1)/2=8
01101* 01001 : Move focus to next bit up.
01101* 01001 : 8 is even, 1-0=1 no borrow. (8-0)/2=4
0110*1 01001 : Move focus to next bit up.
0110*1 01001 : 4 is even, 0-0=0 no borrow. (4-0)/2=2
011*01 01001 : Move focus to next bit up.
011*01 01001 : 2 is even, 1-0=1 no borrow. (2-0)/2=1
01*101 01001 : Move focus to next bit up.
00*101 01001 : 1 is odd, 1-1=0, no borrow. We've completed a subtraction pass and subtracted 34 * 8 from the remainder of last subtraction.
00101 010*01 : Move focus to sixth bit from the left again.
00101 010*01 : 34 is even. 1-0=1 no borrow. (34-0)/2=17
00101 01*001 : Move focus to next bit up.
00101 00*001 : 17 is odd, 1-1=0 with no borrow. (17-1)/2=8
00101 0*0001 : Move focus to next bit up.
00101 0*0001 : 8 is even, 0-0=0 no borrow. (8-0)/2=4
00101* 00001 : Move focus to next bit up.
00101* 00001 : 4 is even, 1-0=1 no borrow. (4-0)/2=2
0010*1 00001 : Move focus to next bit up.
0010*1 00001 : 2 is even, 1-0=1 no borrow. (2-0)/2=1
001*01 00001 : Move focus to next bit up.
000*01 00001 : 1 is odd, 1-1=0, no borrow. We've completed a subtraction pass and subtracted 34 * 4 from the remainder of last subtraction. And shortened the number by 2 bits this time.
00001 00001 : OK so I know that this is less than 34 because it is 32 + 1 = 33, that makes the last subtraction the last one for this pass and we now have a remainder. 33.
Unfortunately the only way to know that at this point is to already understand some binary. since that bit length could be enough to require another subtraction.
00001 00001 : The usual subtraction would just turn this into solid 1s to infinity. 2's complement would work but what would instruct the switch. Maybe all of the subtraction could
be 2's complement. Could they all be added in one series or would the bit flipping be required for every add pass?
00001 00001
- 1 00010
=11111 11111
+ 1 00010
=00001 00001 : So the infinite ones is reversible. And a pretty good sign that your subtraction is done already.
So this is our remainder and so we can move ahead and subtract it from the original number with 2'complement subtraction.
*11110 11110 : Flip all bits.
+11110 11001 : Add in the original number with overlay conversion. Here we will do a short version.
=11101 10111 : 1's complement complete.
+00000 00001 : Add one to get 2's complement.
=11101 11000 : This should be our division ready number. 512 + 256 + 128 + 0 + 32 + 16 + 8 + 0 + 0 + 0 = 952
11101 11000 : Here we need to start applying the subtractions of 34 that will divide evenly into our new number. We know that 34 is even so we know it will be offset by at least one.
11101 11*000 : Focus starts here then we check the least significant bit of the divisor, 34 is even, so the bit will be 0, so offset right, (34-0)/2=17
11101 11-0*00 : Focus is moved right, 17 is odd so this is the position of the fist bit of the divisor subtraction. So we replace the position with 1 to mark the subtraction.
11101 11-1*00 : Now that the answer value is set, return to the original subtraction position. This will always be the next most significant positive bit regardless of how many 0s were offset. So no second marker is needed.
11101 10-1*00 : 17 is odd so 1 - 1 = 0, (17-1)/2=8.
11101 1-01*00 : 8 is even so 1 - 0 = 1, (8-0)/2=4.
11101- 101*00 : 4 is even so 1 - 0 = 1, (4-0)/2=2.
1110-1 101*00 : 2 is even so 0 - 0 = 0, (2-0)/2=1.
110-01 101*00 : 1 is odd so 1 - 1 = 0, end of first subtraction.
11001 1*0100 : Move focus to the next most significant positive bit.
11001 10*100 : 34 is even so offset focus to the right. (34-0)/2=17
11001 0-1*100 : 17 is odd, so mark 1 at current focus then the next most significant positive bit and subtract. 1-1=0, (17-1)/2=8
11001- 01*100 : 8 is even so 1 - 0 = 1, (8-0)/2=4
1100-1 01*100 : 4 is even so 0 - 0 = 0, (4-0)/2=2.
110-01 01*100 : 2 is even so 0 - 0 = 0, (2-0)/2=1.
10-001 01*100 : 1 is odd so 1 - 1 = 0, end of first subtraction
10001* 01100 : Move focus to the next most significant positive bit. At this point I can already see that the next bit will be the last subtraction and the answer will be 11100, but we will finish the algorithm to show how this will fit in.
10001 0*1100 : 34 is even so offset focus to the right. (34-0)/2=17
10000- 1*1100 : 17 is odd, so mark 1 at current focus then the next most significant positive bit and subtract. 1-1=0, (17-1)/2=8
1000-0 1*1100 : 8 is even so 1 - 0 = 1, (8-0)/2=4
100-00 1*1100 : 4 is even so 0 - 0 = 0, (4-0)/2=2.
10-000 1*1100 : 2 is even so 0 - 0 = 0, (2-0)/2=1.
0-0000 1*1100 : 1 is odd so 1 - 1 = 0, end of first subtraction
There are no more positive bits in the register so we are done and we have an answer, 11100 = 16 + 8 + 4 + 0 + 0 = 28
00000 1*1100 : Count is 1.
00000 11*100 : Count is (1*2)+1=3
00000 111*00 : Count is (3*2)+1=7
00000 1110*0 : Count is (7*2)+0=14
00000 11100* : Count is (14*2)+0=28
Total answer is 985 / 34 = 28 remainder 33.
65/5
00000 00001* : 65 is odd, (65-1)/2=32
00000 0000*1 : 32 is even, (32-0)/2=16
00000 000*01 : 16 is even, (16-0)/2=8
00000 00*001 : 8 is even, (8-0)/2=4
00000 0*0001 : 4 is even, (4-0)/2=2
00000* 00001 : 2 is even, (2-0)/2=1
0001*0 00001 : 1 is odd and the end of the conversion.
101 is 5, and easy to remember. And we can tell that 5 divides evenly into 65 so we could skip the subtractions to find reminder and begin the right side division.
00010 00001* : The right side division begins by placing focus at the point in the number that matches the start of the divisor. Since both numbers are odd that is the first bit.
00001 1110*1 : The subtraction is performed and the position is marked with a positive bit that is now part of the quotient.
00001 111*01 : Move focus to the next position that matches the start of the divisor.
00001 01*101 : The subtraction is performed and the position is marked with a positive bit that is now part of the quotient.
00001 01*101 : Move focus to the next position that matches the start of the divisor. This is the next bit up in this case.
00000 0*1101 : The subtraction is performed and the position is marked with a positive bit that is now part of the quotient. This is the last subtraction and we have an answer.
8 + 4 + 0 + 1 = 13
77/7
00000 00001* : 77 is odd, (77-1)/2=38
00000 0000*1 : 38 is even, (38-0)/2=19
00000 001*01 : 19 is odd, (19-1)/2=9
00000 01*101 : 9 is odd, (9-1)/2=4
00000 0*1101 : 4 is even, (4-0)/2=2
00000* 01101 : 2 is even, (2-0)/2=1
0001*0 01101 : 1 is odd and the end of the conversion.
111 is 7 and another easy to remember number. Also 77 is clearly divisible by 7 so we can skip the remainder finding subtraction pass.
00010 01101* : Both numbers are odd so subtraction starts at the least significant bit ( the rightmost ).
00010 0011*1 :
00001 110*11 :
00000 0*1011 :
00000 01011 = 8 + 0 + 2 + 1 = 11
365/9
00000 00001* : 365 is odd, (365-1)/2=182
00000 0000*1 : 182 is even, (182-0)/2=91
00000 001*01 : 91 is odd, (91-1)/2=45
00000 01*101 : 45 is odd, (45-1)/2=22
00000 0*1101 : 22 is even, (22-0)/2=11
00001* 01101 : 11 is odd, (11-1)/2=5
0001*1 01101 : 5 is odd, (5-1)/2=2
000*11 01101 : 2 is eve, (2-0)/2=1
01*011 01101 : 1 is odd and the end of the conversion
1001 is 9 and still pretty easy to remember. Though one can't clearly see that the numbers will evenly divide so we will do a subtraction pass to find remainder.
01011 01101
-01001 00000
=00010 01101
-00010 01000
=00000 00101 : This pass only required 2 subtractions to reach the remainder, 101 = 5.
00000 00101
- 1001
=11111 11100
+ 1001
=00000 00101 : This little diversion shows that the over subtraction reversal works here too. If the ones overflow the register you have subtracted too far. Add back and continue.
*11111 11010 : Invert for 2s complement subtraction.
+01011 01101 : add in the original number. This can be done via another conversion but we are just placing it in place for this example.
=01011 00111 : This is almost complete. Now you must add one to complete the complement.
+00000 00001
=01011 01000 : This is now a cleanly divisible number. Begin the reverse multiplication method. Subtracting from the right where the divisor fits. It is odd so the first one.
01011 01*000 : Mark the space where the subtraction happens.
- 10 01
=01001 0*1000 : The first subtraction done the remaining problem is to the left and the answer so far is to the right.
- 1001
=0000*1 01000 : The answer. 101000 = 32 + 0 + 8 + 0 + 0 + 0 = 40. ( 40 X 9 ) + 5 = 365.
109/22
00000 00001* : 109 is odd, (109-1)/2 = 54
00000 0000*1 : 54 is even, (54-0)/2 = 27
00000 001*01 : 27 is odd, (27-1)/2 = 13
00000 01*101 : 13 is odd, (13-1)/2 = 6 -- Note midway through the conversion the bit value matches our conversion value. This is a coincidence not a rule that holds.
00000 0*1101 : 6 is even, (6-0)/2 = 3
00001* 01101 : 3 is odd, (3-1)/2 = 1
0001*1 01101 : 1 is odd and the end of our conversion.
00011 01101 : 22 is greater than 16 but less than 32 so counting on the knuckles you can see that is no more than 5 bits. So we can begin conversion subtraction there.
00011 011*01 : 22 is even, so subtract 0, no change. (22-0)/2= 11
00011 00*101 : 11 is odd, subtract 1 from 1, leaving 0. (11-1)/2 = 5
00010 1*0101 : 5 is odd, subtract 1 from 0, flip to the 1 in the next column. (5-1)/2 = 2
00010* 10101 : 2 is even, no change. (2-0)/2 = 1
0000*0 10101 : 1 is odd, subtract 1 from 1 leaving 0. The conversion is done. Reading this list back I can see that 22 is 10110. We could compare these numbers to see if
this is the remainder, but instead we will do another subtraction. I will skip the conversion for this one.
00000 10101
- 10110
=11111 11111 : Yup, converts to all 1s. So that was too many subtractions. Time to back up and add 22 back in.
+ 10110
=00000 10101 : So this is our remainder. For the record it is: 16 + 0 + 4 + 0 + 1 = 21
*11111 01010 : Invert for 1's complement.
+00011 01101 : Then add in the 109 with overlay. Showing the simplified version here.
=00010 10111 : This is the 1's complement. Now we must add one to get the 2's complement.
+00000 00001
=00010 11000 : And now we have removed the remainder leaving an evenly divisible number: 64 + 0 + 16 + 8 + 0 + 0 + 0 = 88
So 22 is even, so we know that the starting point for the first subtraction will actually be offset to the right. But how much it would need to be offset is not immediately clear.
So it seems best to start on the first 1 and let the offset slip to the right until the first odd digit is reached.
00010 11*000 : Place focus at the one. 22 is even so move the focus to the right. No change to the bits. (22-0)/2 = 11
00010 110*00 : 11 is odd so we now know where to begin the answer at the current focus point.
00010 11*100 : Now we know where to place the first 1 in the reverse multiplication and can now subtract the rest of the conversion to 22 starting with the first odd bit from 11.
00010 10*100 : 11 is odd, so subtract 1 from 1 leaving 0. (11-1)/2 = 5
00010 0-0*100 : 5 is odd, 1 minus 1 is 0. (5-1)/2 = 2
00010- 00*100 : 2 is even, so no change. (2-0)/2 = 1
0000-0 00*100 : 1 is odd, 1 minus 1 leaves 0. This ends the conversion.
00000 00*100 : There are now no bits to the left of the mark so all that remains is the answer to the right. 100 = 4. So ( 22 X 4 ) + 21 = 109