Square Root: Digit by Digit Algorithm
|
11-25-2022, 06:02 AM
Post: #1
|
|||
|
|||
Square Root: Digit by Digit Algorithm
The following program for the WP-34S is inspired by the this snippet of the HP-45 ROM source code:
Code: 501 L01250: .1111...1. sqt15: c + 1 -> c[p] The registers are mapped to the stack as follows: Z: p Y: c X: a While the program could easily be translated to HP calculators, the INC and SDL commands make it shorter: Code: 001 INC Y Example 41 A 6.4031242374 12 It is recommended to use a number in the range [1, 100), although it works outside of it as well. However, it is more efficient to apply a decimal shift first. So use 47.11 instead of 4711 or 0.4711. Make sure to shift an even number of digits. The program can be helpful to understand the algorithm if you go through an example step by step. References
By now you may have noticed that I didn't pay attention to the exponent. But that's not so interesting in my opinion. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)