Post Reply 
Detect number entry on HP-35s?
02-25-2015, 08:00 PM (This post was last modified: 02-25-2015 08:40 PM by Dieter.)
Post: #12
RE: Detect number entry on HP-35s?
(02-25-2015 07:42 PM)Thomas Radtke Wrote:  
(02-25-2015 07:27 PM)Dieter Wrote:  This sounded like a good idea to me – until I tried it. The 35s does not allow comparing complex numbers (or complex with reals, for that matter).
If he just square it and compare the result against -1?

The 35s supports a genuine complex data type. The result of an operation on a complex number always is complex again. So while i is 0 + 1i, i² equals –1 + 0i, which still is a complex number even if the imaginary part is zero. But there may be a workaround:

Code:
INPUT A
ENTER
ENTER      // save input
0i0        // add 0 + 0i
+          // to turn it into a complex number
ENTER
x          // square it
ARG        // arg(x²) is zero for positive reals
x≠0?       // x² not a positive real?
GTO (exit) // then exit loop
R↓         // restore input
STO(I)     // and process it

This should work.

The only significant limitation is the input range which is limited to values less than 10250.
This could be avoided by testing if abs(cos(arg(x+0i0)))=1. ;-)

Code:
INPUT A
ENTER
ENTER      // save input
0i0        // add 0 + 0i
+          // to turn it into a complex number
ARG        // arg(x) = 0 for positive reals resp. pi/180° for negative reals
COS        // the cosine of this is 1 resp. –1
ABS        // which means that the absolute value is 1
ACOS       // arccos of 1 is zero (one step less than a test against 1)
x≠0?       // was it not a real?
GTO (exit) // then exit loop
R↓         // restore input
STO(I)     // and process it

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Detect number entry on HP-35s? - mbrethen - 02-25-2015, 03:37 AM
RE: Detect number entry on HP-35s? - Dieter - 02-25-2015 08:00 PM
RE: Detect number entry on HP-35s? - d b - 02-26-2015, 06:31 AM



User(s) browsing this thread: 1 Guest(s)