The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

[WP34s] RSD function
Message #1 Posted by Dieter on 27 Jan 2013, 10:22 a.m.

The 34s features a very useful function that rounds a value to a certain number of significant digits - the RSD function. Some time ago I wrote a short program based on the "calculator forensics" routine that determines the perfect result an n-digit calculator should return:

001 LBL A
002 STO 00
003  9
004 SIN
005 RSD->00
006 COS
007 RSD->00
008 TAN
009 RSD->00
010 ATAN
011 RSD->00
012 ACOS
013 RSD->00
014 ASIN
015 RSD->00
016 RTN
Enter a number of digits (n), run the program (preferably in double precision) and the perfect result for a perfect n-digit machine will be returned.
  12  [A]  8,99999864267
  10  [A]  9,000417403
   6  [A]  9,32631
   3  [A]  0
Now try this...
   0  [A]
...and see what you get.

Then single-step through the program and see what happens at step 012/013 where ACOS returns 90 degrees which is then rounded to 0 significant digits.

Finally try the same directly from the keyboard:

   90  RSD 0
and compare the result with the previous one.

Which leads to the question: what is RSD 0 supposed to return?

Dieter

      
Re: [WP34s] RSD function
Message #2 Posted by Walter B on 27 Jan 2013, 12:27 p.m.,
in response to message #1 by Dieter

RSD 0 is rubbish per definition. 1 is the lowest value making sense. We'll catch that bug - thanks for reporting.

d:-)

            
Re: [WP34s] RSD function
Message #3 Posted by Dieter on 27 Jan 2013, 1:16 p.m.,
in response to message #2 by Walter B

Well, in a way RSD 0 can make sense:

0,02   RSD 0  =>  0,01
0,08   RSD 0  =>  0,1
   3   RSD 0  =>  1
   6   RSD 0  =>  10
 314   RSD 0  =>  100
 628   RSD 0  =>  1000
 4999  RSD 0  =>  1000
 5000  RSD 0  =>  10000
But limiting the argument for RSD to values >= 1 is fine by me either. ;-)

Please also note that the current implementation may return different results in run and program mode. 90 RSD 0 here returns either 1E-14 or 10. Maybe you can check this as well.

Dieter

Edited: 27 Jan 2013, 2:07 p.m. after one or more responses were posted

                  
Re: [WP34s] RSD function
Message #4 Posted by Doug (NYC) on 27 Jan 2013, 1:38 p.m.,
in response to message #3 by Dieter

In other words, RSD 0 in Dieter's mind is simply a "power of 10 orders of magnitude" function. It always returns "1. E X", where X is the appropriate order of magnitude. Or, presumably, 0.

Cheers,

Doug

                        
Re: [WP34s] RSD function
Message #5 Posted by Dieter on 27 Jan 2013, 2:03 p.m.,
in response to message #4 by Doug (NYC)

If (!) RSD 0 is accepted it may behave as follows:

 SIGN
 RCL L
 STO+ X
 EXPT
 X<0?     // since SDL and SDR do not accept negative arguments
 SKIP 003 // both cases have to be handled separately
 X<>Y
 SDL->Y
 RTN
 +/-
 X<>Y
 SDR->Y
 RTN
This rounds X to the next closest power of 10. Which IMHO is the logical continuation of the way RSD works otherwise:
  X      RSD 2      RSD 1      RSD 0
------------------------------------
0,333    0,33       0,3        0,1
0,877    0,88       0,9        1
314      310        300        100
682      680        700        1000
-47      -47        -50        -10
-88      -88        -90       -100
------------------------------------
Dieter
                              
Re: [WP34s] RSD function
Message #6 Posted by Walter B on 27 Jan 2013, 4:21 p.m.,
in response to message #5 by Dieter

Interesting continuation of the RSD function. Nevertheless I prefer stopping with RSD 1 for ... ummh ... philosophical reasons. A number can feature one or more significant digits. If it would feature zero significant digits, its overall significance would vanish. Hope this is logical.

d:-)

                  
Re: [WP34s] RSD function
Message #7 Posted by Paul Dale on 27 Jan 2013, 6:49 p.m.,
in response to message #3 by Dieter

Rounding modes?

- Pauli

                        
Re: [WP34s] RSD function
Message #8 Posted by Dieter on 28 Jan 2013, 2:45 p.m.,
in response to message #7 by Paul Dale

RM is 0.

Dieter

                  
Re: [WP34s] RSD function
Message #9 Posted by Walter B on 28 Jan 2013, 4:30 a.m.,
in response to message #3 by Dieter

Dieter,

Quote:
Please also note that the current implementation may return different results in run and program mode. 90 RSD 0 here returns either 1E-14 or 10. Maybe you can check this as well.
I've checked and must confirm this. No idea, however, why
0 COS RSD 0
returns 1e-14. BTW, this occurs both in manual mode and if called from a program - reproducible as it ought to be, at least.

d:-?

                        
Re: [WP34s] RSD function
Message #10 Posted by Dieter on 28 Jan 2013, 2:54 p.m.,
in response to message #9 by Walter B

Try this (in DEG mode):

 0 ACOS   => 90
 RSD 0    => 1E-14
 
 1 ASIN   => 90
 RSD 0    => 1E-14
 
 90
 RSD 0    => 10
Both the emulator (3.2 3350) and the "real thing" (3.2 3360) behave this way. So, in which way is the 90 returned by ACOS different from the same value keyed in manually?

Finally, try this:

 0 ACOS   => 90
 0 +      => 90
 RSD 0    => 10
 
 1 ASIN   => 90
 1 x      => 90
 RSD 0    => 10
 
 90
 RSD 0    => 10
It's hard to describe, but there seems to be some kind of ..."leftover" from the trig function that is removed with the next operation (here +0 resp. x1).

Any idea?

Dieter

Edited: 28 Jan 2013, 2:58 p.m.

                              
Re: [WP34s] RSD function
Message #11 Posted by Walter B on 28 Jan 2013, 2:59 p.m.,
in response to message #10 by Dieter

Quote:
So, in which way is the 90 returned by ACOS different from the same value keyed in manually? ... It's hard to describe, but there seems to be some kind of ..."leftover" from the trig function that is removed with the next operation (here +0 resp. x1).

Any idea?


Not yet. But we are going to get rid of RSD 0 anyway (though this behaviour shall be explained).

d:-)

                                    
Re: [WP34s] RSD function
Message #12 Posted by Walter B on 29 Jan 2013, 8:58 a.m.,
in response to message #11 by Walter B

Build 3363 doesn't allow RSD 0 anymore.

d:-)


[ Return to Index | Top of Index ]

Go back to the main exhibit hall