HP Forums

Full Version: Units
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there something that explains how to use "Units" with variables and programs? Can units be used in programs?

[Image: Units11png.png]
Aside from the user guide, maybe something in this quick program will be useful?

Code:

// Provide a real number value for square meters (without units)

EXPORT units
BEGIN
  LOCAL sqmtrs;
  INPUT(sqmtrs);
  sqmtrs:=sqmtrs * 1_m^2;  
  RETURN CONVERT(sqmtrs / 1_min, 1_ft^2 / 1_s);
END;
Thank you.
Click the [VARS] key, then the [Home] soft menu and click [Real] in the menu. These are all called Real variables. Numbers with units cannot be stored in them. I don't know why. It's just how the Prime works.

You can store numbers with units attached to them if they are User Variables. In your case, you successfully stored 2.3_m^2 into the User Variable 'a'. Other examples of User Variables are MPG, Travel, & bAnAnA.

In this case, I don't know why your conversion fails. Probably because the [STO >] command as a shortcut for converting units is extremely picky on how it's entered. Here are two examples that should convert your example successfully.

In your problem, type [Shift] [Units] [Tools] [ 1 ], recall the 0.50772... and type [ , ] [ 1 ] [Shift] [ _ ] [Shift] [Units] [Units (soft label)] [ 3 ] [ 5 ] [ / ] [Shift] [Units] [ 5 ] [ 7 ] [ENTER].

Or you can recall the 0.50772... and type [STO >] [Shift] [Units] [ H ] [ 6 ] [Enter].
Reference URL's