HP Forums
Units Question - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Units Question (/thread-13291.html)



Units Question - Gene222 - 07-16-2019 10:18 PM

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.


RE: Units Question - roadrunner - 07-17-2019 12:24 AM

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


RE: Units Question - Gene222 - 07-17-2019 01:14 AM

Thanks!