fraction program hp 28s?
|
06-26-2024, 02:13 AM
(This post was last modified: 06-26-2024 02:42 AM by Thomas Klemm.)
Post: #13
|
|||
|
|||
RE: fraction program hp 28s?
To analyse the algorithm I used the following program for the HP-42S:
Code: 00 { 4-Byte Prgm } Example Using Free42: 1 ENTER 0.34 R/S y: 2.941176470588235294117647058823529 x: 0.941176470588235294117647058823529 R/S y: 3.125000000000000000000000000000001 x: 0.0625 R/S y: 50.00000000000000000000000000000002 x: 0 But it's easier to follow if the numbers are written as fractions: y: 1 x: 17/50 y: 50/17 x: 16/17 y: 50/17 * 17/16 y: 1/16 y: 50/17 * 17/16 * 16/1 x: 0/1 Now we can see that this is Euclid's algorithm to calculate the greatest common divisor in disguise. In the Y-register the intermediate values cancel leaving us with 50/1. We may also notice that the first two rounds are a somewhat convoluted way to calculate the fraction part of the number. Instead we could start with: Code: 1 OVER ABS FP Here's the program for the HP-42S: Code: 00 { 28-Byte Prgm } Example 2.34 R/S y: 117 x: 50 I didn't bother to round the result. Also I noticed that for PI I get an Out of Range error message. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
fraction program hp 28s? - Rafa - 06-21-2024, 12:24 PM
RE: fraction program hp 28s? - Gerson W. Barbosa - 06-21-2024, 10:51 PM
RE: fraction program hp 28s? - C.Ret - 06-22-2024, 08:51 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:08 PM
RE: fraction program hp 28s? - Peet - 06-22-2024, 10:44 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:52 PM
RE: fraction program hp 28s? - Rafa - 06-23-2024, 06:43 PM
RE: fraction program hp 28s? - Gerson W. Barbosa - 06-24-2024, 03:03 AM
RE: fraction program hp 28s? - C.Ret - 06-24-2024, 07:39 PM
RE: fraction program hp 28s? - Rafa - 06-25-2024, 01:36 PM
RE: fraction program hp 28s? - C.Ret - 06-25-2024, 05:27 PM
RE: fraction program hp 28s? - Rafa - 06-25-2024, 07:46 PM
RE: fraction program hp 28s? - Thomas Klemm - 06-26-2024 02:13 AM
|
User(s) browsing this thread: 3 Guest(s)