Post Reply 
48-ish units for Prime?
09-12-2018, 10:32 PM (This post was last modified: 09-18-2018 09:47 PM by Gene222.)
Post: #17
RE: 48-ish units for Prime?
(09-09-2018 09:19 PM)StephenG1CMZ Wrote:  If the built-in capabilities of the HP Prime don't suit, you might find my Z_UNITS program helpful, or epp's Convert.
http://www.hpmuseum.org/forum/thread-524...ht=Z_units
http://www.hpmuseum.org/forum/thread-501...ight=Units
But it's not HP-48.

For those who only use a few unit conversions, they might want to consider writing their own custom conversion program, like the one shown here for flow rate conversions. This program requires you to access the conversion sub-programs or functions though the "toolbox" key and "user" tab, as shown in the images below. It saves a couple of key strokes at the sacrifice of versatility. It's a step backwards, but it's quicker. It's like the old calculators that had dedicated unit conversion keys. EDIT 9/15/18. Just make sure you use the correct conversion formula. Corrected the errors in code below. Also, I don't know why the program works without the functions being declared. EDIT 9/18/18. The function names, such as cfs→cms(X1) will not work in CAS mode. CAS will not recognize the → to be part of the function name. To use the programs in CAS mode, all of the function names would have to be changed to something like cfs_cms(X1).

Code:
UnitConv()
BEGIN
END;

EXPORT cfs→cms(X1)
BEGIN
  RETURN 0.0283168465921*X1;  //corrected error
END;

EXPORT cms→cfs(X1)
BEGIN
  RETURN X1/0.0283168465921;  //corrected error
END;

EXPORT mgd→cfs(X1)
BEGIN
  RETURN 1.54722865228*X1;  //corrected error
END;

EXPORT cfs→mgd(X1)
BEGIN
  RETURN X1/1.54722865228;  //corrected error
END;

EXPORT gpm→cfs(X1)
BEGIN
  RETURN 0.00222800925927*X1;
END;

EXPORT cfs→gpm(X1)
BEGIN
  RETURN X1/0.00222800925927;
END;

[Image: 11kwe92.png] [Image: 2gxqmnb.png]

EDIT 9/15/18 Alternatively, for tedious unit conversions that are often used, you can write a similar program using CONVERT. The program below removed the units tag by dividing the variable with the units by its units. The units tag can be left in, if that is what you want. One last thing. If you load both of these programs onto your calculator (UnitConv and Unit), there will be two of each function with the same name. When you run "cfs→cms", the program name and function name will be shown in the display, such as "UnitConv.cfs→cms()", which can clutter the display. So you should delete one of the programs or rename the functions with unique names, so that only the function name is displayed, such as "cfs→cms()".

EDIT 9/18/18. Changed the "→" in the function names to a "_" in the program below, so that the program will work in CAS mode.

In Home RPN mode, you enter the number followed by the function then press Enter, such as 5 cfs_cms() Enter. Or, 5 Enter cfs_cms() Enter.

Code:
Unit()
BEGIN
END;

LOCAL x1;

EXPORT cfs_cms(x1)
BEGIN
  x1:=CONVERT(x1*(1_ft^3/1_s),(1_m^3/1_s));
  x1:=x1/(1_m^3/1_s);  //remove unit tag
  RETURN x1;
END;

EXPORT cms_cfs(x1)
BEGIN
  x1:=CONVERT(x1*(1_m^3/1_s),(1_ft^3/1_s));
  x1:=x1/(1_ft^3/1_s);  //remove unit tag
  RETURN x1;
END;

EXPORT mgd_cfs(x1)
BEGIN
  x1:=x1*1000000;
  x1:=CONVERT(x1*(1_galUS/1_d),(1_ft^3/1_s));
  x1:=x1/(1_ft^3/1_s);  //remove unit tag
  RETURN x1;
END;

EXPORT cfs_mgd(x1)
BEGIN
  x1:=x1/1000000;
  x1:=CONVERT(x1*(1_ft^3/1_s),(1_galUS/1_d));
  x1:=x1/(1_galUS/1_d);  //remove unit tag
  RETURN x1;
END;

EXPORT gpm_cfs(x1)
BEGIN
  x1:=CONVERT(x1*(1_galUS/1_min),(1_ft^3/1_s));
  x1:=x1/(1_ft^3/1_s);  //remove unit tag
  RETURN x1;
END;

EXPORT cfs_gpm(x1)
BEGIN
  x1:=CONVERT(x1*(1_ft^3/1_s),(1_galUS/1_min));
  x1:=x1/(1_galUS/1_min);  //remove unit tag
  RETURN x1;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
48-ish units for Prime? - cvicisso - 09-09-2018, 06:25 PM
RE: 48-ish units for Prime? - StephenG1CMZ - 09-09-2018, 09:19 PM
RE: 48-ish units for Prime? - Gene222 - 09-12-2018 10:32 PM
RE: 48-ish units for Prime? - cvicisso - 09-09-2018, 11:32 PM
RE: 48-ish units for Prime? - Marco Polo - 09-11-2018, 07:45 AM
RE: 48-ish units for Prime? - CyberAngel - 09-11-2018, 08:15 AM
RE: 48-ish units for Prime? - cvicisso - 09-12-2018, 03:40 AM
RE: 48-ish units for Prime? - CyberAngel - 09-12-2018, 03:43 AM
RE: 48-ish units for Prime? - Marco Polo - 09-12-2018, 07:04 AM
RE: 48-ish units for Prime? - DA74254 - 09-10-2018, 01:39 PM
RE: 48-ish units for Prime? - CyberAngel - 09-10-2018, 04:41 PM
RE: 48-ish units for Prime? - cvicisso - 09-10-2018, 07:10 PM
RE: 48-ish units for Prime? - CyberAngel - 09-10-2018, 08:25 PM
RE: 48-ish units for Prime? - cvicisso - 09-11-2018, 02:02 AM
RE: 48-ish units for Prime? - grsbanks - 09-11-2018, 07:32 AM
RE: 48-ish units for Prime? - Carsen - 09-10-2018, 10:46 PM
RE: 48-ish units for Prime? - cvicisso - 09-11-2018, 02:05 AM



User(s) browsing this thread: 1 Guest(s)