[WP34s] RSD function « Next Oldest | Next Newest »

 ▼ Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 01-27-2013, 10:22 AM 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 ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 01-27-2013, 12:27 PM RSD 0 is rubbish per definition. 1 is the lowest value making sense. We'll catch that bug - thanks for reporting. d:-) ▼ Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 01-27-2013, 01:16 PM 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 ▼ Doug (NYC) Unregistered Posts: 26 Threads: 4 Joined: Dec 2012 01-27-2013, 01:38 PM 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 ▼ Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 01-27-2013, 02:03 PM 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 ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 01-27-2013, 04:21 PM 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:-) Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 01-27-2013, 06:49 PM Rounding modes? - Pauli ▼ Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 01-28-2013, 02:45 PM RM is 0. Dieter Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 01-28-2013, 04:30 AM 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:-? ▼ Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 01-28-2013, 02:54 PM 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. ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 01-28-2013, 02:59 PM 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:-) ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 01-29-2013, 08:58 AM Build 3363 doesn't allow RSD 0 anymore. d:-)

 Possibly Related Threads… Thread Author Replies Views Last Post HP50g: Writing a function that returns a function Chris de Castro 2 2,082 12-10-2013, 06:49 PM Last Post: Han [WP34s] Parallel function Dieter 25 5,838 11-05-2012, 04:04 PM Last Post: Marcus von Cube, Germany [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 1,190 10-04-2012, 04:59 PM Last Post: Paul Dale wp34s INC s function Jeff O. 18 4,465 10-03-2012, 02:20 AM Last Post: Paul Dale WP34S Fibonacci function wildpig 3 1,299 09-02-2012, 02:25 AM Last Post: Walter B [WP34S] LocRm allocation function missing? Chris Tvergard 10 3,161 05-14-2012, 10:14 AM Last Post: Chris Tvergard [WP34S] Curious Bug in Inverse Normal Function Les Wright 61 12,556 05-01-2012, 02:44 AM Last Post: Paul Dale [wp34s] Incomplete Gamma on the wp34s Les Wright 18 5,035 12-06-2011, 11:07 AM Last Post: Namir [wp34s] Romberg Integration on the wp34s Les Wright 2 1,457 12-04-2011, 10:49 PM Last Post: Les Wright Stopwatch function implemented on WP34s pascal_meheut 18 4,405 10-29-2011, 06:37 AM Last Post: Marcus von Cube, Germany

Forum Jump: