Practical Uses
The method of complements was used in many mechanical calculators as an alternative to running the gears backwards. For example:
- Pascal's calculator had two sets of results digits, a black set displaying the normal result and a red set displaying the nines' complement of this. A horizontal slat was used to cover up one of these sets, exposing the other. To subtract, the red digits were exposed and set to 0. Then the subtrahend (the number being subtracted) was dialed in. The slat was then moved to expose the black digits (which now displayed the nines' complement of the subtrahend) and the minuend was added by dialing it in. Finally, the operator had to mentally add 1 and ignore the leftmost 1 to obtain the correct answer.
- The Comptometer had nines' complement digits printed in smaller type along with the normal digits on each key. To subtract, the operator was expected to mentally subtract 1 from the subtrahend and enter the result using the smaller digits. Since subtracting 1 before complementing is equivalent to adding 1 afterwards, the operator would thus effectively add the ten's complement of the subtrahend. The operator also needed to hold down the "subtraction cutoff tab" corresponding to the leftmost digit of the answer. This tab prevented the carry from being propagated past it, the Comptometer's method of dropping the initial 1 from the result.
- The Curta calculator used the method of complements for subtraction, and managed to hide this from the user. Numbers were entered using digit input slides along the side of the device. The number on each slide was added to a result counter by a gearing mechanism which engaged cams on a rotating "echelon drum" (a.k.a. "step drum"). The drum was turned by use of a crank on the top of the instrument. The number of cams encountered by each digit as the crank turned was determined by the value of that digit. For example, if a slide is set to its "6" position, a row of 6 cams would be encountered around the drum corresponding to that position. For subtraction, the drum was shifted slightly before it was turned, which moved a different row of cams into position. This alternate row contained the nines' complement of the digits. Thus, the row of 6 cams that had be in position for addition now had a row with 3 cams. The shifted drum also engaged one extra cam which added 1 to the result (as required for the method of complements). The always present tens' complement "overflow 1" which carried out beyond the most significant digit of the results register was, in effect, discarded.
Use of the method of complements is ubiquitous in digital computers, regardless of the representation used for signed numbers. However, the circuitry required depends on the representation:
- If two's complement representation is used, subtraction requires only inverting the bits of the subtrahend and setting a carry into the rightmost bit.
- Using ones' complement representation requires inverting the bits of the subtrahend and connecting the carry out of the most significant bit to the carry in of the least significant bit (end-around carry).
- Using sign-magnitude representation requires only complementing the sign bit of the subtrahend and adding, but the addition/subtraction logic needs to compare the sign bits, complement one of the inputs if they are different, implement an end-around carry, and complement the result if there was no carry from the most significant bit.
The method of complements was used to correct errors when accounting books were written by hand. To remove an entry from a column of numbers, the accountant could add a new entry with the ten's complement of the number to subtract. A bar was added over the digits of this entry to denote its special status. It was then possible to add the whole column of figures.
Complementing the sum is handy for cashiers making change for a purchase from currency in a single denomination of 1 raised to an integer power of the currency's base. For decimal currencies that would be 10, 100, 1,000, etc., e.g. a $10.00 bill.
Read more about this topic: Method Of Complements
Famous quotes containing the word practical:
“Are you being sinister or is this some form of practical joke?
Im trying to come to the point.
I refuse to give up my obsession.
America stop pushing I know what Im doing.
America the plum blossoms are falling.”
—Allen Ginsberg (b. 1926)
“The question of armaments, whether on land or sea, is the most immediately and intensely practical question connected with the future fortunes of nations and of mankind.”
—Woodrow Wilson (18561924)