HP Forums

Full Version: hp35s tell if variable is vector or complex
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to tell if a register is holding a vector or a complex number?

Also I remember there was a thread on if you could tell how many dimensions a vector had and the consensus was that you could not. Has anyone figured out a solution to that problem?
or is there a way to tell if a number is complex or not?

And obviously I mean I am wondering if I can tell inside of a program.
This would require user input, but maybe can help:

VIEW var
SF 10
"COMPLEX? Y=1, N=0"
CF 10
INPUT I // or other dummy variable
x=0?
GTO (label-line number) // If var isn't complex
GTO (label-line number) or next command if var is complex

I was going to suggest using the square root key, but using the square root key on a complex number on the 35S causes an error (silly in IMHO). I have no idea how to mitigate error messages.
(06-27-2016 01:41 PM)Eddie W. Shore Wrote: [ -> ]This would require user input, but maybe can help:

VIEW var
SF 10
"COMPLEX? Y=1, N=0"
CF 10
INPUT I // or other dummy variable
x=0?
GTO (label-line number) // If var isn't complex
GTO (label-line number) or next command if var is complex

I was going to suggest using the square root key, but using the square root key on a complex number on the 35S causes an error (silly in IMHO). I have no idea how to mitigate error messages.

Yes, thanks for the reply. I had a mix of vectors and complex on the stack which I wanted to process, which is why I didn't simply create 2 versions of the program.

Basically I have items in the X Y and Z registers. Each of which could be a complex or vector. I resorted to simply have a utility which does the conversion and staying in all complex for this case.
Reference URL's