HP Forums

Full Version: Units Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way I can test to see if a variable has a unit attached to it?

I was using x:=UVAL(x); where I wanted to strip away the units. If x=5_m, then UVAL returns 5. If x=5 without any units attached, then UVAL returns an error message and it stops my program. I wanted to test x to see if it had units before using the UVAL command.
Syntax:
TYPE(object)

Returns the type of the object:
0: Real
1: Integer
2: String
3: Complex
4: Matrix
5: Error
6: List
8: Function
9: Unit
14.?: CAS object. the fractional part is the CAS type

should do it

-road
Thanks!
Reference URL's