3) Fine tuning
implementation, we have to work a little more on the intermediate iteration:
- simplify the test to -1,
- prepare part 2 of the calculation by reformatting the reminder of the first part.
The key in Cochran’s implementation is that the argument is chosen to be in a 10’s complement form (10 – M).
In fact, driving to 1 is equivalent than driving to zero, but the benefit of this rewriting is simply miraculous then again!
The new form of iteration formula is now (rewriting expression ):
To be clearer with numerical example: if intermediate step is 0.97768 = 0.968 * 1.01, then is 0.02232 = 0.032 (1.01) – 0.01.
We have now
replaced the test to -1 by a simple « carry » test during the subtraction. More
digit left for each
accuracy by suppressing non significant leading zeros, which is very important
when handling numbers like ln(1.00001) qj.
One shift left is equivalent to one multiplication by 10. So we have now:
Another numerical clarification: is now .02232 * 100 = (0.032 * 100) (1.01)) – 1 or again 2.2232 = 3.232 – 1.
For the last iteration (n) the final remainder is then:
In our example: -0.0000322882267342 * 105.
This expression has the right form to start the second part of the calculation and we can add to it the 6 pseudo multiplicands: 7 times ln(1.00001), 6 times ln(1.0001) etc and finally subtract the sum from ln(10).
In practice adding A=00322882267342 and B=00999995000000 7 times will start pseudo quotient calculation qo=7 (see below for details).
Here is a table of the calculation leading to the remainder.
Now, before going into the code, I have to give a few details about the full register use.
I have shown above how the digits are specialized in a word of the HP35’s A&R. For the sake of accuracy we can use almost the whole word except 2 digits in the inner algorithm.
Two digits are used for special purposes (register A):
digit 13 is the SR (shift right) counter used to compute constants (see label
- digit 12 is pseudo multiplication expansion digit: A + B -> A can give a result over 9 at the 11th position.
We must keep in mind that the rest of the register is used to store significant digits during the calculation (regardless their use in the display routines: exponent sign, exponent etc…).
We can understand why the second part of the calculation is started, in our example, with a C register to  ; this is normalized form of the number .32288 etc. the 2 leading digits being specialized.
Note that this value is already aligned with the first multiplicand in the pseudo multiplication process:  . The first value is 3.2288 10-5 and the multiplicand 9.99995 10-5.
The 10’s complement trick simplifies greatly the ln(M) generation.
Please note also, there are very small differences in the last digits of some results of the HP35 ROM trace compared with my examples calculated with Mathematica: not very surprising!