The Museum of HP Calculators


This article is Copyright © 1968 by Hewlett-Packard and is used by permission. The article was originally published in the September, 1968 issue of the Hewlett-Packard Journal. If errors crept in during the scanning process, please contact Dave Hicks

Internal Programming of the 9100A Calculator

By David S. Cochran

EXTENSIVE INTERNAL PROGRAMMING has been designed into the HP Model 9100A Calculator to enable the operator to enter data and to perform most arithmetic operations necessary for engineering and scientific calculation with a single key stroke or single program step. Each of the following operations is a hardware subroutine called by a key press or program step:

Basic arithmetic operations

Extended arithmetic operations

Trigonometric operations

Miscellaneous

In the evolution of internal programming of the Model9100A Calculator, the first step was the development of flowcharts of each function. Digit entry, Fig. 1, seemingly a trivial function, is as complex as most of the mathematical functions. From this functional description, a detailed program can be written which uses the microprograms and incremental instructions of the calculator. Also, each program must be married to all of the other programs which make up the hard-wired software of the Model 9100A.Mathematical functions are similarly programmed defining a step-by-step procedure or algorithm for solving the desired mathematical problem.

The calculator is designed so that lower-order subroutines may be nested to a level of five in higher-order functions. For instance, the 'Polar to Rectangular' function uses the sin routine which uses multiply which uses add,etc.

Addition and Subtraction

The most elementary mathematical operation is algebraic addition. But even this is relatively complex--it requires comparing signs and complementing if signs are unlike. Because all numbers in the Model 9100A are processed as true floating point numbers, exponents must be subtracted to determine proper decimal alignment. If one of the numbers is zero, it is represented in the calculator by an all-zero mantissa with zero exponent. The difference between the two exponents determines the offset, and rather than shifting the smaller number to the right, a displaced digit-by-digit addition is performed. It must also be determined if the offset is greater than 12, which is the resolution limit.

Although the display shows 10 significant digits, all calculations are performed to 12 significant digits with the two last significant digits (guard digits) absorbing truncation and round-off errors. All registers are in core memory, eliminating the need for a large number of flip flop registers. Even with the display in 'Fixed Point' mode, every computed result is in storage in 12 digits.

Multiplication

Multiplication is successive addition of the multiplicand as determined by each multiplier digit. Offset in the digit position flip-flops is increased by one after completion of the additions by each multiplier digit. Exponents are added after completion of the product. Then the product is normalized to justify a carry digit which might have occurred.

Division

Division involves repeated subtraction of the divisor from the dividend until an overdraft occurs. At each subtraction without overdraft, the quotient digit is incremented by one at the digit position of iteration. When an overdraft occurs, the dividend is restored by adding the divisor. The division digit position is then incremented and the process continued. Exponents are subtracted after the quotient is formed, and the quotient normalized.

Square Root

Square root, in the Model 9100A, is considered a basic operation and is done by pseudo division. The method used is an extension of the integer relationship.

i=1..n 2i-1 = n2

In square root, the divisor digit is incremented at each iteration, and shifted when an overdraft and restore occurs.This is a very fast algorithm for square root and is equal in speed to division.

Circular Routines

The circular routines (sin, cos, tan), the inverse circular routines (arcsin, arccos, arctan) and the polar to rectangular and rectangular to polar conversions are all accomplished by iterating through a transformation which rotates the axes. Any angle may be represented as an angle between 0 and 1 radian plus additional information such as the number of times PI/2 has been added or subtracted, and its sign. The basic algorithm for the forward circular function operates on an angle whose absolute value is less than 1 radian, but prescaling is necessary to indicate quadrant.

To obtain the scaling constants, the argument is divided by 2PI, the integer part discarded and the remaining fraction of the circle multiplied by 2PI. Then PI/2 is subtracted from the absolute value until the angle is less than 1 radian. The number of times PI/2 is subtracted, the original sign of the argument, and the sign upon completion of the last subtraction make up the scaling constants. To preserve the quadrant information the scaling constants are stored in the core memory.

The algorithm produces tantheta. Therefore, in the Model 9100A, cos theta is generated as 1/sqrt(1 + tan2theta) and sintheta as tantheta/sqrt(1 + tan2theta)

Sintheta could be obtained from the relationship sintheta =  sqrt(1-cos2theta) for example, but the use of the tangent relationship preserves the 12 digit accuracy for very small angles, even in the range of theta < 10-12. The proper signs of the functions are assigned from the scaling constants.

For the polar to rectangular functions, costheta and sintheta are computed and multiplied by the radius vector to obtain the X and Y coordinates. In performing the rectangular to polar function, the signs of both the X and Y vectors are retained to place the resulting angle in the right quadrant.

Prescaling must also precede the inverse circular functions, since this routine operates on arguments less than or equal to 1. The inverse circular algorithm yields arctangent functions, making it necessary to use the trigonometric identity. sin-1(x) = tan-1(x/sqrt(1 - x2)).

If a cos-1(x) is desired, the arcsin relationship is used and a scaling constant adds PI/2 after completion of the function. For arguments greater than 1, the arccotangent of the negative reciprocal is found which yields the arctangent when PI/2 is added.

Exponential and Logarithms

The exponential routine uses a compound iteration algorithm which has an argument range of 0 to the natural log of 10 (ln 10). Therefore, to be able to handle any argument within the dynamic range of the calculator, it is necessary to prescale the absolute value of the argument by dividing it by ln 10 and saving the integer part to be used as the exponent of the final answer. The fractional part is multiplied by ln 10 and the exponential found. This number is the mantissa, and with the previously saved integer part as a power of 10 exponent, becomes the final answer.

The exponential answer is reciprocated in case the original argument was negative, and for use in the hyperbolic functions. For these hyperbolic functions, the following identities are used:

sinh x = (ex - e-x)/2,  cosh x = (ex + e-x)/2,  tanh x = (ex - e-x)/(ex + e-x)

Natural Logarithms

The exponential routine in reverse is used as the routine for natural logs, with only the mantissa operated upon. Then the exponent is multiplied by ln 10 and added to the answer.This routine also yields these log10 and arc hyperbolic functions:

log10 x = ln x/ln 10;  sinh-1(x) = ln(x + sqrt(x2 + 1));

cosh-1(x) = ln(x + sqrt(x2 - 1));  tanh-1 = ln sqrt[(1 + x) / (1-x)].

The sinh-1(x) relationship above yields reduced accuracy for negative values of x. Therefore, in the Model9100A, the absolute value of the argument is operated upon and the correct sign affixed after completion.

Accuracy

It can be seen from the discussion of the algorithms that extreme care has been taken to use routines that have accuracy commensurate with the dynamic range of the calculator. For example; the square root has a maximum possible relative error of 1 part in 1010 over the full range of the machine.

There are many algorithms for determining the sine of an angle; most of these have points of high error. The sine routine in the Model 9100A has consistent low error regardless of quadrant. Marrying a full floating decimal calculator with unique mathematical algorithms results inaccuracy of better than 10 displayed digits.


David S. Cochran

Dave Cochran has been with HP since 1956. He received his BSEE from Stanford in 1958 and his MS from the same school in 1960. He has been responsible for the development of a broad range of instruments including the Model 3440A Digital Voltmeter and the 204B Oscillator. He has been working on development of electrostatic printing. Dave developed the internal programming for the Model 9100A Calculator.

He holds six patents in the instrumentation field and is the author of several published papers.Dave is a registered professional engineer, a member of IEEE and Tau Beta Pi.

Go back to the HP Journal library
Go back to the main exhibit hall