Ted's Math World Calculator Magic #1:
Introduction

Programming a Four-Function Calculator

Powers, roots, compound interest, trigonometry, logarithms — all these things are possible even on the simplest of units, if you know how.  One could simply purchase a scientific calculator from Hewlett-Packard or Texas Instruments; or else you could enjoy mastering the power of the $4 solar unit that you received in your Christmas stocking or as an advertising promotion.  The results will be perfectly useful, and you can amaze your friends and win barroom bets in the process.

This discussion covers only features that apply to my related pages on specialized calculator application.  Extensive use is made of the Memory and Constant features; but usage of the Percent function isn't covered at all, it being self-explanatory.


ABOUT THE LOGIC CHIP

Important: There are two basic types of of calculator logic:

Just as important:  There are two types of algebraic logic: Casio-style, and virtually all others.  Many retailers such as Radio Shack market units with their own logos, but which are manufactured by other companies.  If you are not sure of your brand's origin, then perform the following test:

Enter 2 × 3 =.  The display will show a {6}.  Now, without clearing, enter 4 =.  If the display shows a {4}, then your unit has Casio-style logic; others will read {8} in the display.

Note: Some newer cheapo Casios don't behave like their predecessors, choosing instead to emulate their inferior competition.  This disappoints me; but more importantly, you need to run the test no matter what.


USING THE CONSTANT (K)

Every pocket calculator has a built-in constant feature, meaning that you can establish a fixed multiplier or divisor to save steps in repetitive calculations.  Although I am a strong detractor of substituting 'K' for 'C' in general (names such as "Kalico Kitchen" and "Krispy Kreme" turn my stomach), but it has a valuable application for us programmers.  Henceforth, this function will be designated as Konstant or perhaps simply K, so as to differentiate from the algebraic meaning of 'constant'.  In keeping with this protocol, Casio units display a 'K' when the Konstant mode is activated.

The following examples set a Konstant value of 2 in order to double a series of numbers:

Non-Casio:

For Casio models: the Konstant is initialized by a double entry of the arithmetic operator:

Konstant mode also is available for the other three arithmetic operators, as follows.

Non-Casio:

Casio:

When using Konstant mode, it can be useful to think of the mnemonic aids — or even mouth them — during a calculation; it may help you to keep track of what you are doing.  Note also that the Casio setup is somewhat more intuitive, in that the Konstant value always is entered first.

Important:  In order to accommodate all types of calculators in program code, the multiplication constant will be denoted as a generic ×(×).  Only Casio users will enter the second '×'.

Equally important:  Some Casios behave differently from others in Konstant mode, regarding their treatment of the M+ and M- keys.  After clearing anything in memory, run this test:

Enter 4 ×× M+ =

If the display shows a 64, then you have an "active" model, which allows the usage of M+ and M- without disrupting the Konstant series.  42 will be in memory, and 43 is the active number.  In other words, pressing M+ includes the function of an equal sign, multiplying the total by 4 as it is copied to memory.

If the display shows a 16, then you have a "passive" model, which allows M+ and M- to cancel Konstant mode.  Pressing M+ placed 42 into memory all right, but the equal sign did nothing.  Passive Casios and other brands need to use an extra equal sign in the code sequence: 4 ×(×) = M+ =

Note: "Active" units save one keystroke on each loop of this type, and this savings is not optional.  Remember that the memory key serves double duty; entering the extra equal sign would add an unwanted increment to the exponent in this particular calculation.


TAKING A RECIPROCAL

Reciprocals also are handled differently by the two types of logic.  If the display shows {8.7} and you wish to take its reciprocal, 1/8.7:

Dividing the {display} into another number is slightly different.  Example: divide {17} into 3:


ABOUT MEMORY

Your calculator might have only a 3-key memory setup; that is, it will have a dual-function MRC button.  One keypress recalls the memory, and a second keypress clears it.  A 4-key setup is preferable, because it is useful to be able to clear the memory and re-use it during a calculation.  One works around that limitation with the following generic protocol:

---

A final note: many online arithmetic calculators — even some on purportedly instructional sites — do not feature a Konstant mode.  That careless omission cripples the utility's functionality, rendering all such sites unsuitable for our purposes.  If you are running Microsoft Windows, then you can use its excellent calculator utility.  I have no familiarity with the offerings of other PC operating systems.

Go Back