6   Storing and Reusing Values

Memory keeps a value available while the stack or expression moves on to other work. Store a conversion factor, a measured quantity, or an intermediate result once, then recall it wherever it is needed. The stored value remains until you replace it or clear its bank; recalling it does not use it up.

SpicyRPN has several memory banks. Ordinary registers serve everyday calculations in both entry modes. Associative memory identifies values by numeric keys in both modes. Statistics and finance use dedicated banks for their own inputs and results. Understanding these distinctions also makes it easier to clear exactly the data you intend to replace.

6.1   The memory banks and their indicators

Table 6.1 summarizes the banks and the display flags that announce their contents. A flag means that the bank contains at least one stored entry, including an explicitly stored zero. It does not identify which register is occupied, show a count of entries, or certify that the data is appropriate for your next calculation.

Table 6.1: Stored data and its occupancy flags.

Bank

Flag

Purpose and access

Ordinary

MEM

Ten registers, R0–R9, for values you choose. STO and RCL work in RPN and ALG.

Associative

ASSOC

Values stored under numeric keys. Access through the orange functions of STO and RCL in both modes.

Statistics

STAT

Six accumulators for observations, sums, and products. RPN keys or ALG STAT worksheets.

Financial

FIN

The five registers n, i, PV, PMT, and FV. Shared by both entry modes.

Cash flows

CF

An initial flow and subsequent equally spaced flows, entered and used in both modes.

These banks are separate from the working stack. In RPN, X is stack position S0, and Y is S1. R0 is ordinary memory register 0, not another name for S0. Similarly, the statistical sample count and the financial period count are distinct values even though both are conventionally written \(n\).

The memory flags describe shared banks in either entry mode. A STAT, FIN, or ASSOC flag describes the same stored data whether you use RPN commands or ALG worksheets. The banks and their flags survive closing and reopening the application; see section 6.8.

6.2   Ordinary storage and recall

Choose any digit from 0 through 9 as a register number. To store, press STO, then that digit. To recall, press RCL, then the digit. For example, STO 3 selects R3. The digit is a destination, not a new number being entered. There is no second digit in an ordinary register address.

STO and RCL are the unshifted memory keys beside the statistics controls in RPN and beside the expression controls in ALG. Pressing either key arms a command: the STO or RCL flag and status prompt show that a target is pending. The operation finishes when you choose its register. Any number still being typed is committed at that point.

An unshifted backspace cancels a pending ordinary STO or RCL without deleting a digit. CLx or CLEAR also cancels that pending command rather than clearing an operand. The header’s CANCEL dismisses the entire pending selection, including an arithmetic STO modifier and any active shift, while preserving your unfinished entry. With only a shift active, pressing it again also cancels it. See section 6.10 for MCLR selectors.

In RPN

The current X (S0) and Y (S1) hold working operands. The separate Last X and Last Y hold previous operands saved by commands; they are not stack positions.

STO copies X into the selected register. It replaces any previous value there and leaves the stack and both saved operands, Last X and Last Y, unchanged. You can therefore store a result and continue calculating with it.

Ordinary RCL lifts the recalled value into X. The previous X moves to Y, with deeper values moving one position farther away. It also saves that previous X in Last X; Last Y is unchanged. If you were typing a number, recall first commits it, then moves it to Y as the recalled value enters X. The normal fixed-stack limit or unlimited-stack rules apply, as described in chapter 2.

Put a result aside, then use it again

Use RPN, real mode, a fixed stack of 5, and FIX 4, with no active shift or pending command. This example replaces R2; other memories may contain anything. Clear the stack with f CLEAR, the orange function of \(1/x\), then enter:

12 ENTER 3 \(\times \) STO 2

The display remains 36.0000, and R2 now contains 36. Clear the stack again and calculate with that value:

f CLEAR 9 RCL 2 +

Recall commits 9 and puts 36 in X, with 9 in Y. Addition gives 45.0000. R2 still contains 36.

In ALG

STO stores the current operand or completed result. It commits an active numeric entry but does not evaluate the whole unfinished expression. With \(2+3\) entered and no = yet pressed, STO 2 stores 3. To store the sum, press = first, then STO 2.

RCL inserts the recalled value where an operand is expected. If the expression already ends in an operand, it replaces that last operand, including a completed parenthesized group or function result. After a completed calculation, recall starts a new expression containing the recalled value. It does not append a second operand by implicit multiplication. Neither ordinary storage nor recall changes ANS; the next successful = updates that answer.

Store an operand or store the expression’s result

Use ALG, real mode, and FIX 4, with no active shift or pending command. The main CLEAR key clears the expression; this example deliberately replaces R2.

CLEAR 2 + 3 STO 2

The unfinished expression is still \(2+3\), the current value is 3.0000, and R2 contains 3. Continue with:

= STO 2

Now the display and R2 both contain 5. Try each row below independently. Each starts by clearing the expression, and all use this same stored 5.

Key sequence

Result

CLEAR 10 + RCL 2 =

15.0000

CLEAR 10 + 99 RCL 2 =

15.0000

CLEAR 12 = RCL 2 =

5.0000

In the first row, recall supplies the missing operand. In the second, it replaces 99. In the third, it begins a new expression after 12.

6.3   Arithmetic storage

You can change a stored value without recalling it, performing arithmetic on the stack or in the expression, and storing it again. Press STO, then one of the four arithmetic keys, then the register digit. The operator modifies the pending storage command; it does not perform the ordinary on-screen arithmetic operation.

Let \(M\) be the value already in the destination and \(v\) the current operand: X in RPN, or the current ALG operand or completed result. The order is always \(M\) followed by the operator and \(v\), as shown in table 6.2.

Table 6.2: Arithmetic storage in ordinary register R3.

Sequence

New R3 Pending flag

STO + 3

\(M+v\) STO+

STO \(-\) 3

\(M-v\) STO\(-\)

STO \(\times \) 3

\(M\times v\) STO\(\times \)

STO \(\div \) 3

\(M/v\) STO\(\div \)

Subtraction removes the current operand from memory; division divides memory by the current operand. Both operations leave the current operand in place. In RPN they preserve all stack positions and both Last registers after committing any entry. In ALG they leave the expression unevaluated and use the same current-operand rule as ordinary storage. To add an expression’s total to memory, finish it with = before pressing STO +.

An unset register supplies zero as \(M\). Thus adding 5 to an unset register stores 5, subtracting 5 stores \(-5\), and multiplying an unset register by 5 stores zero. Each successful operation creates a stored entry. Division by a zero current operand reports an error and leaves the destination unchanged.

Reduce and divide a stored amount

Use RPN, real mode, a fixed stack of 5, and FIX 4, with no active shift or pending command. The following sequence initializes R1, so its previous contents do not matter:

f CLEAR 20 STO 1 5 STO \(-\) 1

R1 now contains \(20-5=15\), while the display is 5.0000. Continue:

3 STO \(\div \) 1 RCL 1

The arithmetic store changes R1 to \(15/3=5\) and leaves 3 in X. Recall then displays 5.0000, with 3 in Y.

6.4   Reusing a constant

A stored constant lets several calculations use exactly the same value. Choose a register, store the factor, and recall it for each calculation. A result’s displayed decimal places do not limit what STO saves: storage and recall use the underlying digits, not the rounded display. Both complex components are copied when CMPLX is on; with CMPLX off, only the real component is copied, as explained in section 6.5. Display changes do not round the contents of a memory register. See chapter 5 for the separate effects of working and display precision.

Apply one scale factor to three quantities

Use RPN, real mode, a fixed stack of 5, and FIX 4, with no active shift or pending command. Set R0 to the scale factor 2.5:

f CLEAR 2.5 STO 0

Then follow each row. Clearing the stack between quantities keeps the examples independent and preserves the stored factor.

Key sequence

Scaled quantity

f CLEAR 12 RCL 0 \(\times \)

30.0000

f CLEAR 18 RCL 0 \(\times \)

45.0000

f CLEAR 7.2 RCL 0 \(\times \)

18.0000

There is no need for ENTER between a quantity and RCL: recall finishes its entry and lifts the factor into X.

To use the same factor in ALG, select ALG, retaining real mode and FIX 4. With no pending command, enter:

CLEAR 12 \(\times \) RCL 0 =

The result is again 30.0000. Both modes use the same R0.

If a constant needs higher precision, recompute it and replace its stored value; see section 5.7.

6.5   Complex values in memory

The complex setting determines the value written by a store or recall. With COMPLEX on, both components of the value are copied. With it off, only the real component is copied and the destination’s imaginary component is zero. This applies to ordinary and associative memory, financial-register and cash-flow assignments, and the working register or ALG operand receiving a recall. Arithmetic storage also uses the current complex setting. Statistical calculations and financial formulas use real components even with CMPLX on; their newly computed results and statistical totals are real.

Changing the setting does not rewrite existing memories. A complex value stored while CMPLX is on keeps both components when CMPLX is turned off. Recalling it in real mode creates a real working copy; the source memory remains unchanged. Turn CMPLX on and recall it again to obtain the original pair. In contrast, storing into that memory while CMPLX is off replaces its old pair with a real value, even if the source operand still has a hidden imaginary component.

Newly saved Last X and Last Y values follow the same rule. Merely moving existing stack values by lifting, dropping, swapping, or rolling preserves their components; an idle ENTER creates a new copy in X, so that copy is real when CMPLX is off. See section 8.6 for a complete store/recall example.

6.6   Unset registers and stored zero

Recalling an unset ordinary register returns zero without creating an entry in that register. The recall therefore does not light MEM. By contrast, entering zero and pressing STO followed by a digit stores a real entry whose value happens to be zero; MEM is then present.

The same distinction underlies all occupancy flags. An unmatched associative key returns zero without creating a pair. Statistical accumulators can contain zeros and still occupy their bank. Removing observations until the sample count is zero does not empty that bank. A zero financial input remains stored, and a cash-flow list containing zero-valued flows still lights CF.

Consequently, a zero recall alone cannot tell you whether a particular register was never used, was cleared, or explicitly contains zero. Nor can MEM identify which of the ten ordinary registers is occupied. Use deliberate initialization when the distinction matters. For example, start an ordinary running total by storing zero in its chosen register, then use STO + for each amount.

Overwriting one register with zero preserves the other registers but does not remove occupancy. The grouped MCLR operation removes entries from its selected bank; it is not an individual-register selector. A complete demonstration appears in section 6.10.

6.7   Associative memory: values under numeric keys

Associative memory lets a number identify another number. For example, you can use an item number as the key for its measured value. These keys are numeric values, not text names and not ordinary register numbers. Key 123 in associative memory has no connection to the ordinary digits used after STO or RCL.

In RPN, the associative commands use stack operands. Orange f STO selects the legend \(\mathrm {STO}_{xy}\); orange f RCL selects \(\mathrm {RCL}_{x}\). Unlike ordinary storage and recall, these commands act immediately on operands already on the stack. There is no following register-selection digit.

Keys match by numerical equality, not by the spelling of their entry. For example, exact values entered as 1 and 1.0 identify the same key; storing again replaces the earlier value. A rounded display is not an equality test: two computed keys that both display as 1.0000 may have different hidden digits and fail to match. Exact, easily repeated keys such as integers are convenient. The key’s real component must not be NaN; its imaginary component is ignored.

To store a pair, put the value in Y and its key in X. In the usual entry sequence, type the value, press ENTER, then type the key and press f STO. Storage saves the old X and Y in Last X and Last Y, then drops the key from X. The stored value moves down from Y into X. A fixed stack repeats its deepest value; an unlimited stack shrinks by one and must have both operands.

To retrieve the value, put its key in X and press f RCL. Recall replaces the key with the stored value, without lifting the stack. It saves the key in Last X and preserves Last Y. A key with no matching entry is replaced by zero.

Look up a value by item number

Use RPN, real mode, a fixed stack of 5, and FIX 4, with no active shift or pending command. This example stores 42 under key 123, replacing any existing value with that matching key. Other associative entries may remain.

f CLEAR 42 ENTER 123 f STO

The display returns to 42.0000; the key has been dropped. ASSOC is present, Last X contains 123, and Last Y contains 42.

To add the stored value to 9, enter:

f CLEAR 9 ENTER 123 f RCL +

Typing 123 places 9 in Y. Associative recall replaces 123 with 42 while leaving 9 in Y; addition gives 51.0000. The stored pair remains available.

Associative memory in ALG

Worksheet fields and recalled outputs must be finite. If an entry stored from RPN contains NaN or infinity, associative recall in ALG reports an error rather than making that nonfinite value an output.

Orange STO, labeled \(\mathrm {STO}_{xy}\), opens a worksheet with Key and Value. Enter and accept both fields with ENTER, then choose STORE. This writes the pair only after both inputs validate. Orange RCL, labeled \(\mathrm {RCL}_{x}\), opens a worksheet with Key; accept it, then choose RECALL. The output is the stored value, or zero if there is no match. Choose Use value to insert it into the suspended expression.

With complex mode on, the Value field can contain a complex expression. The real-key and component-copying rules in the note above apply here. The primary output of successful STORE or RECALL updates ANS; accepting a field updates ANS too. No RPN stack value or Last register participates.

For example, accept Key 123 and Value 42, then STORE. To use it in \(9+42\), return to the calculator, start \(9+\), open associative recall, accept Key 123, choose RECALL, then Use value and =. The answer is 51. CANCEL closes the worksheet without inserting an output; completed storage remains. The shared worksheet rules are in section 4.12.

6.8   Memories, working areas, and saved operands

RPN and ALG keep independent working areas but share the memory banks. Storing in R3 in ALG replaces the value that RPN will later recall from R3. Mode switching preserves each working area without transferring a value; see section 4.10.

The effects of the main RPN memory commands are collected in table 6.3. Here X means the current S0 and Y the current S1; the Last registers hold separately saved previous operands. All effects refer to the committed operands: if a number is being entered, it is finished before the command acts. Ordinary and arithmetic storage preserve operands; recall and associative storage have the movements shown. When CMPLX is off, each new memory value, recalled working value, and saved Last operand is real, as described in section 6.5.

Table 6.3: RPN memory effects after any active number is committed.

Command

Stack effect

Saved operands

Ordinary STO, including arithmetic storage

No movement; X stays in place.

Both Last registers preserved.

Ordinary RCL

Lift recalled value into X.

Old X becomes Last X; Last Y preserved.

Associative f STO

Store Y under key X, then drop X.

Save the key in Last X, the value in Last Y.

Associative f RCL

Replace key X with its value; no lift.

Save the key in Last X; Last Y preserved.

Financial STO, including arithmetic storage

No movement; X stays in place.

Both Last registers preserved.

Financial-register RCL

Lift recalled value into X.

Both Last registers preserved.

ALG memory operations do not touch the suspended RPN stack or its Last registers. They act on the ALG operand or expression as described in section 6.2. Clearing an ordinary ALG expression, or using CLx or CLEAR on the RPN working area, leaves all these memory banks intact.

Stored values, the independent working areas, and pending commands are saved automatically. Relaunching does not empty a register or cancel a partly entered STO sequence. Read the command flags before resuming. Saved operands are also not a backup of a memory bank: LAST X and LAST Y cannot undo a store or reconstruct cleared memories. See chapter 2 and chapter 14.

6.9   The statistical and financial banks

Statistics

The statistical bank holds six accumulators: the sample count \(n\), \(\sum x\), \(\sum x^2\), \(\sum y\), \(\sum y^2\), and \(\sum xy\). Adding or removing observations changes these totals; it does not maintain a retrievable list of the original observations. The statistics commands in both modes use this bank without borrowing ordinary registers for the running accumulation.

\(\mathrm {RCL}_{\Sigma }\), the blue function of L.R., copies those six totals into ordinary registers R4–R9, in the order shown below. This overwrites any values already stored there. The statistics bank itself is unchanged, and the command does not lift six values onto the stack.

Ordinary register R4 R5 R6 R7 R8 R9
Copied total \(n\) \(\sum x\) \(\sum x^2\) \(\sum y\) \(\sum y^2\) \(\sum xy\)

You can then inspect a total with ordinary RCL and its digit, including after switching to ALG. Even when the statistical bank is empty, copying its totals stores six zeros and lights MEM without lighting STAT. Subsequent changes to the observations do not update the copied values; repeat the copy when you need fresh totals. Chapter 10 covers sample entry, correction, and the statistical results.

Financial registers and cash flows

The five financial registers hold the period count n, the interest percentage per period i, present value PV, periodic payment PMT, and future value FV. In RPN, their main keys on the Financial panel are also targets for explicit storage and recall. Use STO PV to store X in PV, for example, or RCL PV to lift its value onto the stack. Arithmetic storage works with these targets too. Explicit STO chooses storage regardless of whether the next bare financial key would otherwise solve for a variable.

In RPN, bare financial keys either store or solve, according to the preceding action. After an explicit financial store, the next bare financial key solves; an ordinary recall permits the next bare financial key to store. For the complete store/solve rules, input signs, rate periods, and payment timing, follow chapter 11. A solve uses all four other financial registers, including stored zeros. An old payment or future value can therefore affect a new problem until you replace it or clear it.

The cash-flow bank is a separate sequence used for NPV and IRR. Its commands also use the financial n register as an index. In particular, \(\mathrm {CF}_0\) starts a new cash-flow list and stores \(n=0\), so it lights FIN as well as CF, even when the initial flow is zero. Indexed storage and recall use \(\mathrm {CF}_j\) as their target and have different operand requirements from financial-register storage; use the procedures in chapter 12.

For separate financial clears in either mode, orange f FV selects \(\mathrm {CL}_{fin}\) and removes the five financial registers while leaving cash flows. Blue g FV selects \(\mathrm {CL}_{cf}\) and removes the cash-flow list, but also stores zero in n; FIN therefore remains present. The financial MCLR group clears both banks together. In ALG, bare register keys always store the current operand; CPT followed by a register explicitly solves it. Financial recall inserts like ordinary RCL. The cash-flow keys open labeled worksheets; STO or RCL followed by CFj opens indexed storage or recall. See section 11.12 and section 12.9.

6.10   Clearing the intended group with MCLR

MCLR is the blue function of STO. With no existing shift or pending command, press g STO. The MCLR flag appears and the prompt asks you to choose a group. The next key selects the group to clear, as summarized in table 6.4. Its ordinary function is not performed. Do not insert a shift between MCLR and a desired selector: it cancels MCLR instead of choosing an alternate legend.

Table 6.4: One-key selection after g STO has armed MCLR.

Press next

Mode

What is cleared

0

RPN or ALG

All ordinary registers and all associative entries. Entry/arithmetic keys except backspace select this group.

\(\Sigma +\)

RPN

All six statistical accumulators. The mean and L.R. keys select the same group.

n

RPN or ALG

All five financial registers and the entire cash-flow list. Any Financial-panel key selects this group.

R\(\downarrow \)

RPN

The whole RPN stack and unfinished RPN entry. \(x\leftrightarrow y\) and \(1/x\) select the same group.

CANCEL or backspace

RPN or ALG

Nothing: cancel MCLR. Either shift or physical Escape also cancels. A shift press is consumed and leaves no shift active.

The digit 0 in the first row is a convenient selector for the entire ordinary-and-associative group. It does not mean “clear only R0.” The entry/arithmetic group includes the digits, decimal point, EEX, sign change, operators, and ENTER or =. In ALG, every Expression key—the parentheses, FUNC, CPT, and CLEAR—and the entry key \(1/x\) also select this memory group. In RPN, \(1/x\) belongs to the stack group instead.

Keys outside the clearing groups, such as a Scientific-panel key or STO/RCL themselves or ALG’s ANS, also cancel MCLR without performing their normal function. The group is determined before ordinary key routing.

You may swipe to the Financial panel while MCLR is pending; paging does not consume the command. In either mode, pressing n then clears both financial banks without performing its ordinary action. For the MCLR statistics or stack selector, use RPN. ALG also provides Clear statistics through its STAT worksheets.

Clearing a memory bank removes its entries and corresponding occupancy flags while preserving the active number or expression, the working stack, and both Last registers. It does not even finish an unfinished numeric entry. Clearing the stack group instead discards the RPN entry and zeros the stack, preserving both Last registers and all memory banks. Neither operation resets precision, display format, angle units, complex mode, or payment timing. MCLR is a group clear, not a factory reset.

Distinguish an empty bank from a stored zero

This example intentionally removes all ordinary and associative memories. Use it when you are ready to discard those entries. Use RPN, real mode, a fixed stack of 5, and FIX 4, with no active shift or pending command.

f CLEAR 84 STO 9

R9 contains 84 and MEM is present. Now press:

g STO 0

All ordinary and associative entries have been removed. Their flags are absent, but X still displays 84.0000. Press RCL 9. The display becomes 0.0000, 84 moves to Y, and MEM stays absent because recall has not created an entry.

Finally press STO 9. This stores the recalled zero in R9. The display is still 0.0000, but MEM is now present. The display value is the same; the bank’s occupancy is different. Statistical, financial, and cash-flow data are unchanged throughout.