HP Forums
hp35s tell if variable is vector or complex - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: hp35s tell if variable is vector or complex (/thread-6430.html)



hp35s tell if variable is vector or complex - dalupus - 06-18-2016 11:01 PM

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?


RE: hp35s tell if variable is vector or complex - dalupus - 06-21-2016 12:45 AM

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.


RE: hp35s tell if variable is vector or complex - Eddie W. Shore - 06-27-2016 01:41 PM

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.


RE: hp35s tell if variable is vector or complex - dalupus - 06-27-2016 04:01 PM

(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.