[34S & 31S] Unique display mode: significant figures
02-12-2015, 04:33 AM (This post was last modified: 02-12-2015 04:53 AM by Bit.)
Post: #21
 Bit Member Posts: 265 Joined: Jan 2014
RE: [34S & 31S] Unique display mode: significant figures
(02-12-2015 02:50 AM)mendesp Wrote:  Thank you Nigel for your answer. I understand your reasons. With all respect to your code and Bit's work, do you think I could "easily" modify it so the SIG display could be used like I wish ?

Could you then point me the code lines I would have to modify ?

Please see the patch below, it seems to do what you asked for but I only tested it for a few seconds.

Code:
diff -ur wp34s_r3748/keys.c wp34s_sig_arg_1_r3748_20150211/keys.c --- wp34s_r3748/keys.c    2015-02-07 13:09:17.000000000 -0500 +++ wp34s_sig_arg_1_r3748_20150211/keys.c    2015-02-11 23:22:24.032343895 -0500 @@ -1252,6 +1252,7 @@      const unsigned int val = State2.digval * 10 + n;      const int is_reg = argcmds[base].reg || State2.ind;      int lim; +    int arg_shift = 0;            if (State2.local) {          // Handle local registers and flags @@ -1272,6 +1273,14 @@          lim = (int) argcmds[base].lim;                // any other command          if (lim >= RARG_IND && argcmds[base].indirectokay)              lim = RARG_IND - 1; +#ifdef INCLUDE_SIGFIG_MODE +        if (base >= RARG_SIG && base <= RARG_SIG0) { +            if (n == 0) +                return STATE_UNFINISHED; +            lim++; +            arg_shift = 1; +        } +#endif      }      if ((int) val > lim)          return STATE_UNFINISHED; @@ -1279,7 +1288,7 @@      State2.digval = val;      ++State2.numdigit;      if ((int) val * 10 > lim || State2.numdigit >= num_arg_digits(base)) { -        int result = arg_eval(val); +        int result = arg_eval(val - arg_shift);          if ( result == STATE_UNFINISHED ) {              --State2.numdigit;              State2.digval /= 10; @@ -1399,6 +1408,8 @@              break;          }          CmdBase = base; +        if (base != RARG_FIX && !State2.ind && State2.digval == 0) +            State2.numdigit = 0;      }  #endif      /*

You'll need to instruct your patch utility to ignore whitespaces, otherwise it'll probably complain about tabs. On the command line, it's usually the -l (lower case L) option.

Edit: The above code changes the UI but not how programs are interpreted or displayed, nor how values taken from registers are used... that's left as an exercise for the reader.
02-12-2015, 05:35 PM
Post: #22
 mendesp Junior Member Posts: 19 Joined: Oct 2014
RE: [34S & 31S] Unique display mode: significant figures
Thanks a lot Bit for your help. I modify the code as your instructions (I had no idea how to apply a patch, but I'll find out and everything seems to work fine.

Thanks again !

Regards,

Patrick
02-13-2015, 10:03 PM
Post: #23
 matthiaspaul Senior Member Posts: 373 Joined: Jan 2015
RE: [34S & 31S] Unique display mode: significant figures
For easier future reference, there's another interesting thread dealing with significant figures over here:

Greetings,

Matthias

--
"Programs are poems for computers."
 « Next Oldest | Next Newest »

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