34s work-around for 41c quirk



#8

The HP 41 SIGN command returns +1 for a value of 0.

The 34s returns 0 for a value of 0.

So, what's an efficient way to code around this difference?

Could be:

X=0? 
SKIP 01
SIGN

What do you think?


#9

Quote:
The HP 41 SIGN command returns +1 for a value of 0.

Yes. And that makes sense. The idea behind this is the ability of the HP41 to check for alpha data:
HP-41 series:
SIGN returns
+1 for x>=0 (i.e. also for x=0)
-1 for x<0
0 if x contains alpha data
If you want a plain "mathematical" sign-function on the '41, simply use
   X<>0?
SIGN
which requires just a single byte more.

So, returning 1 even for x=0 was and is okay on the HP-41 series since it has an additional benefit. But why should one duplicate this feature on another, different calculator whithout this special background that is the reason for this ..."special" behaviour? Do we really need a SIGN41 function on the 34s ?-)

BTW, as far as I see the code you proposed will not change anything, If x is zero the sign command is skipped and x remains zero (not one). If you really want to duplicate the HP-41 way, this could be done with

   X=0?
INC X
SIGN
But, as already mentioned, I don't think this makes sense on the 34s.

Dieter


#10

My initial thought was that it should work. But you are right, it doesn't. Your solution does however.

I guess if you were converting an HP-41 program this might be useful.

#11

Dieter is correct and suggested the same workaround I thought of when I saw the question :-) The only difference with the workaround is Last X is set incorrectly when X is zero.

We've a total inability to distinguish alpha data from numbers unlike the 41 series. I think I could work around this with reals either by reducing the number of digits by one or reserving lots of NaN values as alpha data. This is pointless since we also support integers for which there is no space available to distinguish.

This is something that will definitely be addressed in the 34S successor. I'd still differ from the 41 series though. SIGN would still return -1, 0, +1 for negative, zero and positive numbers. We've got NaN for the string case :-)


- Pauli


#12

I am converting some HP 41 programs that store a -1 or 1 depending on the value in X.

Don't think LastX will be a problem, so I think Dieter's approach will work.

I am not advocating for a SIGN41 function. :-) and I like the SIGN function on the 34s, just wanting to make sure I had not overlooked something...

Edited: 12 Aug 2011, 6:51 p.m.


#13

Quote:
I am not advocating for a SIGN41 function. :-) and I like the SIGN function on the 34s, just wanting to make sure I had not overlooked something...

Don't worry there is no chance of a SIGN41 function :-)

There is a better solution that does Last X correctly too:

    SIGN
X=0?
INC X

Put this into a S41 subroutine if you are keen.


- Pauli

#14

Quote:
The HP 41 SIGN command returns +1 for a value of 0.

The 34s returns 0 for a value of 0.

So, what's an efficient way to code around this difference?

Could be:

X=0? 
SKIP 01
SIGN

What do you think?


No, that won't work: it gives 0 if x=0 (because it just skips the SIGN in this case).

If you replace SKIP 01 by 10^x (or e^x) it would work as you want!

Franz

PS: Dieter's solution INC X is indeed better (because faster) than my 10^x - I'm just not used to this INC X because none of my other calculators has it.

Edited: 12 Aug 2011, 6:31 p.m.


Possibly Related Threads...
Thread Author Replies Views Last Post
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 276 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  Another Prime mystery - templates don't work anymore Michael de Estrada 2 212 11-02-2013, 11:34 AM
Last Post: Michael de Estrada
  Does the HP Prime software only work with Win 7/ 8 ? Michael de Estrada 3 264 10-12-2013, 02:52 PM
Last Post: John Ioannidis
  Back to School/Work/Other Calculator Poll Eddie W. Shore 63 2,878 09-12-2013, 06:03 AM
Last Post: bhtooefr
  How I use my HP50G at work. David Bengtson 7 340 05-06-2013, 02:57 PM
Last Post: Ingo
  Does IR printing not work on your converted WP34s? Then read on... Harald 3 263 04-04-2013, 05:46 PM
Last Post: Harald
  No luck getting flash disk to work in 95lx Harald 7 502 03-18-2013, 08:11 AM
Last Post: Harald
  35s refuses to work Silvio A. Bensi 19 1,070 10-18-2012, 12:48 AM
Last Post: Reth
  HP-33S Display Quirk Matt Agajanian 4 206 05-15-2012, 08:31 AM
Last Post: Michael de Estrada
  How does the HP-97 printer paper feed work? Harald 5 279 03-31-2012, 09:31 AM
Last Post: Harald

Forum Jump: