[42S] looking for decimal to rational fraction - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: [42S] looking for decimal to rational fraction (/thread-12218.html) |
[42S] looking for decimal to rational fraction - cdmackay - 01-17-2019 11:38 PM I was looking for a program to do decimal to fraction conversion on the 42S (well, DM42). I found this older thread, where user Xose posts a link to his code at a now defunct website. The Internet Archive had a single copy of that page here, but it contains some odd characters, and I'm unsure how to deal with them. You can see them at the link, and here's an excerpt from the downloaded file: Code: 00 { 163-Byte Prgm } see e.g. lines 1, 13 & 20. How do I enter those? Or is the listing corrupted? thanks very much… RE: [42S] looking for decimal to rational fraction - cdmackay - 01-17-2019 11:44 PM Ah! Comparing with the 41C prog further down the page, looks like most of them are the 42S's extended RCL commands combined with an arithmetic, e.g. RCL+ But what might the odd chars before LBL be? The 41C listing has those too… RE: [42S] looking for decimal to rational fraction - rprosperi - 01-18-2019 12:01 AM (01-17-2019 11:38 PM)cdmackay Wrote: How do I enter those? Or is the listing corrupted? I'd say they are corrupted, or at least were not recognizable when pasted into the listing. Note the 'bad' characters are not random. Every label has one, a few (but not all) RCL xx statements, plus lines 13, 20, and 70. Probably Thomas will recognize what is unique/common about the affected lines. Of course you can ignore the bad characters in the Labels and RCL lines; just skip the bad character (though for the RCL lines they could be RCL+ nn). As the original values are no longer present, it will be hard to figure out what is missing for the 3 empty lines, unless you can figure out the intended algorithm (I can't). Sorry, not much help.... RE: [42S] looking for decimal to rational fraction - cdmackay - 01-18-2019 12:17 AM thanks Bob, it will be an exercise for me to get it working, the RCLxx bits are a good start RE: [42S] looking for decimal to rational fraction - ijabbott - 01-18-2019 12:26 AM (01-17-2019 11:38 PM)cdmackay Wrote: I was looking for a program to do decimal to fraction conversion on the 42S (well, DM42). Use right-click "View Frame Source" in the Chrome browser to get a better view of the source. The funny characters before the LBL are just to make the labels stand out on the listing and can be ignored. The characters on lines 13 and 20 are the 'divide' operator. Code: ****************************** RE: [42S] looking for decimal to rational fraction - Thomas Okken - 01-18-2019 12:47 AM You can get Ian's cleaned-up Version into the DM42 without retyping it, as follows: First, remove the funny characters in front of the LBLs (all seven of them) and replace them with spaces. Next, find the five lines that start with +" (plus sign followed by double quote) and change those plus signs to |- (vertical bar followed by minus sign) Then, copy the program text and paste it into Free42 in PRGM mode. Check your work by making sure the pasted program has the right number of lines and bytes. You can now use Export Programs to create a raw file, which you can transfer to the DM42 and load there. RE: [42S] looking for decimal to rational fraction - rprosperi - 01-18-2019 01:24 AM (01-18-2019 12:26 AM)ijabbott Wrote: Use right-click "View Frame Source" in the Chrome browser to get a better view of the source. The funny characters before the LBL are just to make the labels stand out on the listing and can be ignored. The characters on lines 13 and 20 are the 'divide' operator. Nice tip, thanks Ian. View Frame Source works in FF as well. (01-18-2019 12:47 AM)Thomas Okken Wrote: You can get Ian's cleaned-up Version into the DM42 without retyping it, as follows: See what I mean... RE: [42S] looking for decimal to rational fraction - cdmackay - 01-18-2019 07:55 PM thanks very much indeed Ian & Thomas, much appreciated. RE: [42S] looking for decimal to rational fraction - cdmackay - 01-18-2019 08:20 PM (01-18-2019 12:47 AM)Thomas Okken Wrote: … Alternatively for those without Free42 to hand [why not? ] this decoder also works perfectly (once Thomas's corrections are made): https://www.swissmicros.com/dm42/decoder/ RE: [42S] looking for decimal to rational fraction - cdmackay - 01-18-2019 08:36 PM hmm. although it works perfectly on Free42 Decimal Mac, it gets a Size Error on Free42 Android, and Invalid Type on DM42. further assembly required… RE: [42S] looking for decimal to rational fraction - cdmackay - 01-18-2019 09:18 PM There were two problems: first, on my Free42 Android, somehow the REGS matrix had disappeared, causing the Size Error. A SIZE 25 sorted that out. However, the program appears to be a little brittle regarding the stack contents when it starts. It starts by jumping to LBL 11, which saves the stack contents into R07–R10: Code: 01 LBL "FRACT" and it restores them when it's done. Unfortunately, those STO fail if there's something on the stack that can't be saved into a register, causing the Invalid Type. For example, a matrix, if you've just done a SIZE 25 That's fixed by putting some reals on the stack first. Normally not likely to be an issue, but not ideal. |