Get email delivery of the Cadence blog featured here
I hope you had a great July 4th long weekend if you are in the US...and if you were elsewhere I hope you at least had a good short weekend. Today is the first of three posts on "carry", in the sense you first learned in primary school, where adding 3 to 19 requires you to carry 1 to get to 22. But we'll start a little indirectly!
If you are young enough, then you've had electronic calculators all your life, and the way you would do any calculation is simply to enter it into the calculator. So when you learned physics, in particular, you'd just take the physical formula and enter the actual values. For example, the period of a pendulum is given by:
T = 2π × √(L/g)
T = 2π × √(L/g)
where L is the length of the pendulum in meters, g is the acceleration due to gravity (which is 9.8 m/s2 on earth), giving you the period in seconds. So you might end up having to calculate:
2 × π ×√ ( 1.673 / 9.8 )
and you'd just type a few keys on your calculator and you were done.
But when I was at school, electronic calculators hadn't been invented yet (and remember, the first microprocessor was invented to build an electronic calculator...but that's a story for another day).
Of course, you could do a calculation like the one above for simple enough numbers using long multiplication, long division, and either look up the square root in a table of square roots, or use one of the procedures for calculating it explicitly. However, for complex calculations where there might be many numbers, each with many digits, this was not practical. You would use log tables to avoid ever needing to do multiplication or division (except by small integers).
Here's how that worked. You would convert all the numbers in the equation to their logarithms (using a book of tables that every student owned a copy of). Then do the calculation since log(A×B) = Log(A) + log(B), and log(A/B) = log(A)-log(B), and the log(√ A) = log(A)/2. So doing the calculation only involves addition, subtraction, and dividing by 2, all of which are easy to do with pencil and paper. That would give you the logarithm of the number you wanted, so you'd then look that up using the log tables backwards, or using a table of antilogarithms. A slide rule worked using logarithmic scales, basically turning multiplication into addition of lengths that you could accomplish by using the slide and the cursor.
If this all seems rather laborious and complicated, it was. But remember how complicated long multiplication and long division are. I hope kids are not forced to learn how to do long division with pencil and paper anymore—in this day and age it has to be one of the most useless skills I acquired growing up. Well, of course, knowing how to use log tables and slide rules is also pretty useless these days.
Before there were electronic calculators there were mechanical calculators, like the one pictured. The simplest operations were to add and subtract. You would zero out the total, enter a number, turn the handle, enter the next number, turn the handle again, and so on. You could work your way down a column of figures and add them all up. To subtract, you turned the handle the other way. You couldn't do multiplication or division directly.
The calculators actually had a movable carriage to hold the total, and you could use that to do multiplication by repeated addition. To calculate, for example, 257 × 74563, you would enter the longest number 74563, With the carriage fully to the left (units position), you'd turn the handle seven times, then move the carriage one space to the right to the tens position, turn the handle five times, move the carriage once more, and then turn the handle twice. You could then read out the answer. I think the other number, that kept track of the handle turns, should now read the other number, 257, to confirm that you did it correctly.
If that seems complicated, here's how you had to do division, such as 74563 / 257, by repeated subtraction. You would zero the machine, enter 74563, and add it in to get your starting value. Then you enter 257. Move the carriage so that the 745 you entered was aligned with the 2 of 257 (or further to the right—you'll still get the right answer but you are just wasting time). Now you repeatedly subtract as many times as you can until either you notice that you have a number less than 257 in the 3 digits above the 257, or else you don't notice. Since the machine didn't actually have any representation for negative numbers, what happened was that all the leftmost digits rolled back from 0 to 9 with an impressive mechanical noise. You then turned the handle one turn back again to correct the overshoot. Move the carriage one place to the left, and repeat. When you've done this in the units position, the display that counted all the handle turns is the quotient and the remainder is left to be read off the machine, it was literally what remained after doing all those subtractions.
Electromechanical calculators would automate this process for multiplication and division. Division, in particular, was impressive, subtracting until the number "carried" to all 9s, adding the overshoot back in again, and then moving the carriage, and repeating. Remember, there is zero electronics (transistors) in this machine. The school I went to had exactly one machine like this, and a few manual machines. For everything else, there were log tables and slide rules.
This video isn't exactly the machine my school had, but it is similar, and you can see it doing multiplication and division:
Here's a video of what is going on inside a mechanical calculator with all the skins taken off. The most interesting bit is at the 2-minute mark when the carry mechanism is explained.
If you watched the video above then you saw how the carry mechanism works. One of the challenges in any mechanical calculator is handling the carries. When you add 1 to 9, getting the first digit to rotate to 0 is easy, but there has to be a mechanism to increment the digit to the left by one. In older cars, the mechanical odometer had a similar problem. It gets more complex still when you add 1 to 9999 since the carry needs to work across 5 digits to increment the 10000 digit. There has to be some sort of mechanical mechanism so that when a 9 rolls over to 0 it also triggers the extra step of adding 1 to the digit to the left. But that might, in turn, roll from 9 to 0 and so trigger the extra step again.
Handling carries efficiently is one of the biggest challenges of any mechanical calculating machine. Electronic, too, as it happens.
Tomorrow, how carry is handled in what have to be the most famous mechanical calculating machines ever designed.
Sign up for Sunday Brunch, the weekly Breakfast Bytes email.