Post Reply 
(12C) Programming Tricks
10-07-2016, 06:43 PM (This post was last modified: 10-07-2016 06:48 PM by Dieter.)
Post: #3
RE: (12C) Programming Tricks
Eddie, thank you for this collection of useful tips for the 12C and other calculators.
Let me add a few remarks:

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Multiply x by 100

Keystroke: [ENTER], 1, [x<>y], [%T]
Result: The X stack has 100*x, the Y stack has x.

I'd say the Y-register after this procedure is 1, not x.

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Quickly entering numbers in the form of 10^n (n is an integer)

Keystrokes: 1, [EEX], n
This is useful when n>2. For example, entering 10000 takes five steps normally. With this sequence, 1 [EEX] 5, you only use 3.

Actually only 2. The "1" is not required, a simple [EEX] 5 does it.

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Another Way to Double

Keystrokes: [ENTER], [ + ]
Results: X Stack: 2*x. 1 program step saved.

It depends. In most cases "2 [x]" does it, an initial [ENTER] is not required. So both methods usually take the same two steps. On the other hand the proposed method saves X in LstX which can be helpful.

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Absolute Value of x.

Keystrokes: 2, [y^x], [ g ] [ √ ]
Result: X Stack: |x|. It is important to square the number first since the HP 12C’s square root function returns an error on negative numbers.

Instead of using the power function, [ENTER] [x] usually is faster. This applies to most calculators.

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Signum Function of x.
This is the extension of the absolute value sequence shown previously.

Keystrokes: [ENTER], 2, [y^x], [ g ] ( √ ), [ ÷ ]
Result: X Stack: sgn(x)

There's one ENTER missing.
[ENTER] [ENTER] [x] [g] [√] [÷]
Or maybe [ENTER] [ENTER] 2 [x^x] [g] [√] [÷]

(10-06-2016 07:41 PM)Eddie W. Shore Wrote:  Modulus (for two positive values)

Keystrokes: a, [ENTER], b, [ ÷ ], [ g ] (LSTx), [x<>y], [ g ] (FRAC), [ * ]
Result: X stack: a MOD b

This can cause roundoff errors. Better use a mod b = a – b * int(a/b):
a [ENTER] [ENTER] b [÷] [g] [LSTx] [x<>y] [g] [INTG] [x] [–]
This requires one more stack register (Z) but it returns exact results.

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


Messages In This Thread
(12C) Programming Tricks - Eddie W. Shore - 10-06-2016, 07:41 PM
A very handy collection - striegel - 10-07-2016, 12:53 AM
RE: (12C) Programming Tricks - Dieter - 10-07-2016 06:43 PM



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