Japanese abacus and binary arithmetic
Soroban or counting tray is a vertical abacus with 5 beads that is divided into two rows. Higher row has one bead and lower row has 4.
Every column in a soroban signifies a digit. The lone higher bead has a value of 5 and lower beads each has a value of 1. The value of the column is decided by the amount of beads touching the middle bar that divides the Soroban.
Mastering the four basic arithmetic operations on Soroban is said to boost your calculation skill. I think there is a very good reason for this. A physical tool allows you to memorize the arithmetic operations into a mantra that you can apply without thinking about it.
Addition & Subtraction
The use of Soroban for addition relies on the complement of 5 and 10.
1+4 = 2+3 = 3+2 = 4+1 = 51+9 = 2+8 = 3+7 = 4+6 = 5+5 = 6+4 = 7+3 = 8+2 = 9+1 = 10
So say you have to add A to B. If complement of A is higher than B, then there is no carry. Otherwise there is a carry.
A+B < 10 when B < (10-A)A+B = +10+A-(10-B) when B >= (10-A)
Likewise at subtraction you can also use the complement to ease computation.
A-B >= 0 when B <= AA-B = -10+A+(10-B) when B > A
Next consider you have to calculate this:
42933 + 13749* * * *
The stars mark the calculations that produce complements. You can rewrite the number to this:
42933 + 130403 1 1 1
This is a shorthand for 42933 + 13040 - 300 - 1 + 1000 + 10.
When you carry out the simpler calculations you end up
with no complementary number combinations and you can just
sum every number together like this:
42632 + 14050 = 56682The result is the same as of the original calculation.
You can do the same with the subtraction:
42933 - 26872* * * *42933 - 208024 3 1 146963 - 30902 = 16061
The logic is similar, but the complementary numbers are added instead of subtracted, and the carry is subtracted instead of added. We mark the numbers that are smaller than the numbers on the another side.
What does happen with adjacent complementaries?
4693 + 5379!!** **4693 + 5300!!31 11
You can see that the rules work fairly well because we end up subtracting. I intentionally chose a corner case where we get an additional complementary.
4693 + 5000!631 1 14693 + 00004631 1 10093 + 000031 1 10062 +10010 = 10072
Digits that add up to 9 can carry. This may seem like a problem to use of this algorithm, but they clear down to zero if they interfere with the calculation.
In the subtractive case the carrying digits are the same, which makes them easy to recognize.
These rules are practically the same as with ordinary arithmetic that you may have been taught so there should be nothing new for you in this drill.
How do these rules manifest in a soroban? Well practically they should be simpler because the soroban represents digits using fewer digits.
This is how the digits would manifest in a soroban:
55 5 554143 + 324
Now lets try the same algorithm to calculate the sum and mark the carrying digits:
!!*! *0550 50554143 + 0324!!** **
I found this to be a bit tricky because the higher column behaves differently than the lower. In other hand it is much simpler.
!!*! *0550 50554143 + 0324!!** **!! ! 10500 50054143 + 0324!!** **
The large carry makes it look as if the whole number just collapsed.
!0000 00050043 + 0024** 1 **0000 00500043 + 001031 10000 0050 000500012 +10010 = 10022 = 10072
Here we are doing rather clumsy calculations on the paper, but lets do it again as if we were actually using a soroban to calculate the sum:
18233 + 99777005000 55555013233 + 44222055000 5555013233 + 4422205000 5555103233 + 422205000 555112233 + 22205500 55112233 + 22205500 55112433 + 2205550 5112433 + 2205000 5113003 + 205005113003 + 205000113010 = 118010
It is a long sequence of events but it really did not take much time at all. Literally everybody knows how to add and subtract together small numbers and the use of Soroban exploits that fact.
Knowing how Soroban adds numbers together also helps you in understanding how computers add numbers together. Here's the same computation done using the binary numbers:
! !! *!* !!!! ! *00 0100 0111 0011 1001 + 01 1000 0101 1100 0001
The information about the carry and hazard of carrying further already tells us everything we need to know about the result.
01  1100 1100  1111 1010 = 118010The logic of addition reduces into small pieces that can be implemented in handful of logic gates.
0+0+0 => 0, 0+1+0 => 1, 1+0+0 => 1, 1+1+0 => 20+0+1 => 1, 0+1+1 => 2, 1+0+1 => 2, 1+1+1 => 1+2
The additive circuit can also double as subtraction circuit if we use two's complement to represent negative numbers.
Two's complement
When two's complement is used with binary numbers, the most significant digit is interpreted as if it extended infinitely to the left. These four numbers are all the same number:
11110101 = -11111110101 = -111111110101 = -1111111110101 = -11
To get the negated number value, you flip the bits and add one.
~11110101+1 = 00001010+1 = 11Therefore our algorithm for adding numbers together remain the same, yet we have obtained a way to subtract numbers and represent a negative sign. We can verify this by observing that the negative and positive number cancels each other out.
!!!!!!!*11110101 + 00001011 = 0
So Soroban's arithmetic resembles binary arithmetic because the rules to memoize are reduced in count. Can we use this idea of complementary numbers with Soroban? We can try to derive the rules.
42933 - 26872 = 1606100500 05550 0505042433 - 21322 = 11011
So what is the negation of 26872 in soroban representation?
Observing that the complementary representation must cancel out,
we should produce a complementary number with an expectation that
the number cancels out.
The complementary number would be:
550005423122+1
It is as if we subtracted every digit from 9, then added 1.
We can see that this number cancels out with the positive number during negation:
!!!!!!550005 005550423123 + 021322 = 0!!!!!*
Now we can try whether the addition with this complementary produces the result that we wanted:
000500 550005 005050042433 + 423123 = 011011500500 50005442433 + 23123550500 0005442433 + 23123000500 005012433 + 3123005500 05010433 + 123005000 5011033 + 23005050 5011003 + 3005055011003 + 3005050011011
Therefore complementary number notation does work with a soroban, which means we only need to know how to invert the orientation of the beads and add one to represent negative numbers.
Multiplication
The multiplication of numbers together requires a multiplication table. The multiplication table for decimals goes:
12 43 6 94 8 12 165 10 15 20 256 12 18 24 30 367 14 21 28 35 42 498 16 24 32 40 48 56 649 18 27 36 45 54 63 72 81
Low number of digits makes the multiplication easier. For reference, here's the multiplication table for the binary:
0 00 1
That is a ridiculous multiplication table. So how does multiplication of two numbers proceed in binary?
00 0100 0111 0011 1001 * 01 1000 0101 1100 00010110000101110000010000000000000000000010001110011100100000000000000000000010001110011100100000000000000000000000000100011100111001000000000000000000000000000010001110011100100000000000000000000000000000100011100111001000000000000000000000000000000100011100111001000000000000000000000000000000000000100011100111001000000000000000000001101010110101011000000000000000000000 000 00 00000000000000000000000000001000111001110010000000000000000000000000000100011100111001000000000000000000000000000001000111001110010000000000000000000000000000001000111001110010000000000000000000000000000000000001000111001110010000000000000000000011010111111001001100100000000000000000000000000 000 00 0000000000000000000000000000001000111001110010000000000000000000000000000010001110011100100000000000000000000000000000010001110011100100000000000000000000000000000000000010001110011100100000000000000000000110110000111001100111010000000000000000000000000000 000 00 00000000000000000000000000000001000111001110010000000000000000000000000000001000111001110010000000000000000000000000000000000001000111001110010000000000000000000011011000101110100111001100000000000000000000000000000 000 00 00000000000000000000000000000000100011100111001000000000000000000000000000000000000100011100111001000000000000000000001101100011011110000011111000000000000000000000000000000 000 00 00000000000000000000000000000000000000100011100111001000000000000000000001101100011011110100100011111001000000000000000000000000000000000000 000 00 000110 1100 0110 1111 0100 1000 1111 1001
What is the multiplication table for the Soroban?
010 02 40 5 53 1 40 5 0 54 3 12 115 0 5 0 50 10 10 20 20
We have 10 numbers to memorize and they all follow
some blatantly obvious patterns.
The five is ridiculously simple,
whereas four is following
a similar pattern that 9 follows in decimal.
Two-four and Three-one-four are some trivial
number sequences for the two and three.
The multiplication follows the exact same rules as multiplication with decimals or binary numbers. So I am not going to show an example of that using Soroban notation. Note that the multiplication also works with the complement numbers.
Division
The division is the most difficult from the four steps, but in binary it's not that difficult when we use the methods that we have used so far to the other operations.
000100011100111001 / 01110, the -01110 is 10010The strategy usually used for division is to transfer the number being divided into a remainder. Then we start subtracting multiples of the dividing number until we end up with a number that is smaller than the divider.
00000001000000000000010001110011100111110010000000010010000000000000111100111001111111100100000000101000000000000001000001110011111111001000000001010001000000000000010011100111111111110010000000010100010100000000000001011001111111111111001000000001010001011000000000000010000111111111111110010000000010100010110000000000000000101111111111111110010000100011100111001 / 01110 = 010100010110 + 0101 / 01110
How to do this with a Soroban?
18233 / 14 = 1302 + 5 / 140500013233 % 140000004233 % 14 + 10000000004233 % 14 + 10000050002333 % 14 + 11000000001433 % 14 + 12000000000033 % 14 + 13000000500014 % 14 + 13010000500000 % 14 + 1302
The method of long division can be used without a problem. It is essentially same as used with the binary numbers.
The long division with Soroban can be sped up by calculating a multiplication table for the divider. This is achieved by adding the number to itself five times.
IEEE Floating point soroban
You could create an abacus with pairs of three beads in it, used and organized similar to the Soroban. This "hexadecimal" Soroban could be directly used for representing floating point arithmetic.
Here's a floating point soroban that represents infinity:
+INF----------------------------------| | | * * * * * * * * * * * * || * * * * * * * * * * * * * * |- * * * * * * * * * * * * * * |* * * | | | | | | | | | | | | ||--------------------------------|| * * | | | | | | | | | | | | |- * * * * * * * * * * * * * * || * * * * * * * * * * * * * * || | | * * * * * * * * * * * * |----------------------------------
If the significand is not zero, this table would be NaN.
+NaN(0h.4)----------------------------------| | | * * * * * * * * * * * * || * * * * * * * * * * * * * * |- * * | * * * * * * * * * * * |* * * * | | | | | | | | | | | ||--------------------------------|| * * | | | | | | | | | | | | |- * * * * * * * * * * * * * * || * * * * * * * * * * * * * * || | | * * * * * * * * * * * * |----------------------------------
Now you can see yourself that floating point format uses a lot of states for representing NaN.
Exponent zero represent denormal numbers. They are numbers that start with zero. The smallest representable number would be shown like this:
+0h0.000000000001*2^(-126)----------------------------------| * * * * * * * * * * * * * * || * * * * * * * * * * * * * * |- * * * * * * * * * * * * * * |* | | | | | | | | | | | | | | ||--------------------------------|| | | | | | | | | | | | | | * |- * * * * * * * * * * * * * | || * * * * * * * * * * * * * * || * * * * * * * * * * * * * * |----------------------------------
If the exponent is nonzero, we get normalized values.
+0h1.000000000000*2^(-126)----------------------------------| * * * * * * * * * * * * * * || * * * * * * * * * * * * * * |- * | * * * * * * * * * * * * |* | * | | | | | | | | | | | | ||--------------------------------|| | | | | | | | | | | | | | | |- * * * * * * * * * * * * * * || * * * * * * * * * * * * * * || * * * * * * * * * * * * * * |----------------------------------
This is the quantity of 1:
+0h1.000000000000e0*2^(0)----------------------------------| * | * * * * * * * * * * * * || * * * * * * * * * * * * * * |- | * * * * * * * * * * * * * |* * * | | | | | | | | | | | | ||--------------------------------|| * * | | | | | | | | | | | | |- * * * * * * * * * * * * * * || * * * * * * * * * * * * * * || | | * * * * * * * * * * * * |----------------------------------
What could you do with this? You could demonstrate how the value underflows if the exponent differs by more than 48 steps. You can also explain why some decimal fractions do not have an exact representation in floating point values. Plus you can explain why the floating point rounding error accumulates or how the error magnifies when values are subtracted from each other.
The computation would involve shifting the beads into the right orientation. This would involve left and right shifts.
1011 0000---------**---------***
Right shift: If the slot has at least two beads, leave odd number of beads. If the slot has odd number of beads, leave at least two beads to the next slot.
0101 1000---------** *---------*
Left shift: If the slot has odd number of beads, leave more than two beads. If the slot has at least two beads, leave odd number of beads to the previous slot.
0001 0110---------*---------* **
Maybe there will be more ideas later.
Conclusion
Use of a Soroban in training could help to train mechanized rules for basic arithmetic and dramatically speed up the performance of calculating arithmetic by memory.
The speed-up could be used for teaching more of numerical methods for solving problems that would be otherwise infeasible due to lot of computation required to solve the problem.
The knowledge gained from operating with a Soroban can translate to the understanding of computers and computer arithmetic.