Power-of-two fraction handling for the 41C
|
06-02-2016, 03:54 PM
(This post was last modified: 06-04-2016 01:19 PM by 4ster.)
Post: #17
|
|||
|
|||
RE: Power-of-two fraction handling for the 41C
I really like Dieter's first version (below) since it is compact and I don't mind the occasional "0/1" fraction portion of the answer. After having it on my calculator for a while I bought a "Thermal & Transport Science Pac" module. An unexpected (for me) feature of the module is that it has a fairly powerful unit management system that can be incorporated into user programs. After playing with it a while it dawned on me that with some simple additions to Dieter's program I could do full, fractional conversions to imperial unit systems.
See the "Thermal & Transport Science Pac" manual for details on how the conversion system works. Conversion examples, entered in the alpha register before running D2F: CM-IN (centimeters to inches with 1/8, 1/16, 1/32... precision by storing 8, 16, 32... in R00) M-YD (meters to yards and feet, by storing 3 in R00) KG-LBM (kilogram to pounds and ounces of mass by storing 16 in R00) I made the following additions to Dieter's program: At line 02, 5 lines are inserted: FS? 01 EXQ 03 (If flag 01 is set a unit conversion is run on the input before being fractionalized) FS? 55 VIEW X (if a printer is present it prints the converted, digital, input) ASTO 01 (stores unit conversion string to put back into the alpha register at the program's end) At line 27 insert: CLA (to clear the alpha register of the conversion string) At line 40 insert: CLA (clears the alpha register of the fractionalized answer) ARCL 01 (Puts the unit conversion string back into alpha so its ready for another input.) GTO 04 LBL 03 VIEW X (prints the input) AVIEW (prints the conversion type to be be run) -SI (The unit conversion sub-routine on the Thermal module) RTN LBL 04 END Usage: If I want to run the unit conversion before fractionalizing the number I enter the unit conversion string into alpha and set flag 01. Note that since register 1 is temporarily used to store the alpha string of the unit conversion, that string is limited to 6 characters. KG-LBM is fine, KGF-LBF (kilogram force to pound force) is seven characters so will not work. Most of the valid conversions strings are 6 characters or less. If a printer is attached, the program prints four items: the original input, the conversion string used, the conversion, and the fractionalized conversion. (02-01-2016 07:10 AM)Dieter Wrote:(02-01-2016 02:06 AM)quantalume Wrote: OK, I shall then. We can compare code when I finish. Steve In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)