This is the manual for Stak. There is no manual for Stak16 yet.

Stak is a Java RPN calculator. It is currently available for Nokia Series 40 phones with three softkeys, such as the Nokia 6230. A version for desktop computers is also available.

Stak is primarily designed for mobile phones, and has a few features intended to overcome the fact that the shape and number of keys on a mobile phone is not ideal for a calculator.



Stak uses RPN (Reverse Polish Notation) on a rolling stack, like many Hewlett-Packard calculators. In RPN, the operands are entered before the operator, so to calculate "2 + 3" the user enters the numbers 2 and 3 then adds them. More complicated expressions, such as "4 * (3 + 5 * 7)", must be parsed by the user and entered as:

4 ENTER 3 ENTER 5 ENTER 7 * + *

Not everyone thinks this is fun, but it has several advantages, in particular for a calculator in a mobile phone.

Most calculations that can reasonably be done on a mobile phone calculator are not written down as expressions first, but comes out of understanding a specific problem, and writing them down is often an extra step.

Another big advantage is that RPN requires fewer keys than algebraic entry.

Stak has a 4-level stack like classic HP calculators, not an infinite stack as in the HP48/49 (RPL) calculators. The way the enter key works also differs between the classic RPN and the RPL calculators. Stak can work either way, but defaults to the simpler way the RPL calculators use.

In this manual, the top of the stack (the one in the display of an HP calculator) is called the X register and the register above is called the Y register.

Unnormalized arithmetic

Stak uses unnormalized arithmetic as described by Mike Cowlishaw in the General Decimal Arithmetic Specification at

In unnormalized arithmetic, the result of an operation remembers the number of digits in the operands. This means that while 2 + 2 is 4, 2.0 + 2.0 is 4.0. Trailing zeros can be removed with the NORM (Normalize) operation.

Stak has 15 digits of precision in the coefficient, and can work with exponents from -1013 to 999.

The asymetric exponent range is due to support of gradual underflow as specified by the IEEE 854 standard. Another effect of Stak following a standard designed for computers and not calculators is that in some situations the result of an operation can be a negative zero. It is equal to a positive zero. Zero can have an exponent like any other number, so results like 0E+3 (zero thousand) or 0.000 are not bugs.


The display consists of three parts:

A line separates the X register from the rest of the display. The status line is written in a smaller font. The two upper parts of the display are replaced in help mode or in a menu.

The status line contains information of the current state. It shows the exponent format, the current flags and the most recent operations.


The keyboard has 3 shift states, switched with the '#' key. Operations are not executed immediately when a key is pressed, but when it is released. Stak shows the operation in brackets in the status line when a key is pressed, and if it is held down the operation is cancelled (this is similar to the HP 41 calculator).

If the shift ('#') key is held down the operation is cancelled (like other operations), and a map of the keyboard in the current shift state is shown on the display. Holding shift down or executing an operation removes the keyboard map.

Keyboard layout

The first row on the map is the left and right softkeys and the up key. Second row is the left/right keys and the center key. Third row is RING, the down key and the END keys which closes the program. The remaining rows are the standard 12-key phone keyboard.

1st shiftstate
, EEX02nd
2nd shiftstate
3rd shiftstate

Memory Mode and Argument History List

Stak enters a special memory mode for storing and recalling values from memory. In memory mode a register (out of 100) is selected, either with the up/down keys or by entering a number, and then an operation is choosen. All the mathematical operations are available. Unary operations, such as 1/X are performed on the register, and binary

Operations, such as + or / are performed on the register and the X register, with the result in the register.

The argument history list is an extension of the "Last X" function in HP's calculators. Instead of just the last value in the X register, it stores the last 100 arguments used in operations in a list, where they can be recalled just like memory values. Binary operations are available, they work on the value in the X register and the element in the history list.

In memory or history mode some of the keys in the first three rows are different:

1st shiftstate
2nd shiftstate

Some functions are disabled in memory or history mode. They are grayed out in the keyboard map.


The MODES dialog contains these items:

Format'All' or 'Fixed'. Show all digits or with a fixed decimal.
Show dec.How many decimals to show in Fixed format. This option is hidden if the format is All. All digits are shown, with exponent if necessary, if the number is too large or is rounded to zero. If the number is rounded a tilde '~' is shown in the left column. Default is 2.
Exp. formatSCI or ENG. Exponential notation is used if the exponent of the value is larger than zero or the exponent of the highest digit of the value is larger than -6.
Dec. sep.The decimal separator can be '.' (full stop) or ',' (comma).
1000 sep.The thousands separator can be '.' (full stop), ',' (comma), "'" (apostrophe) , ' ' (space) or none.
Time sep.Time separators can be '0:0:0.0', '0°0'0"0' or '0h0hm0s0'
DigitsSwitch the digit set between up to 18 different, depending on the character sets supported by the phone (in practice much less than 18). The supported digits are: European, Arabic-Indic, Eastern Arabic-Indic (Persian and Urdu), Bengali, Devanagari, Gujarati, Gurmukhi, Kannada, Khmer, Lao, Malayalam, Mongolian, Myanmar, Oriya, Tamil, Telugu, Thai, and Tibetan
Trig modeSwitch between degrees and radians
StackliftThe stack lift (enter key) can be Classic, as in HPs RPN calculators, or New, as in RPL calculators.
Stack sizeDepth of the stack, from 4 (default) to 16

Values can be toggled with the left softkey or reset to the default value with the RING key.


Entering values
<- and -> begins editing of the value in the X register. CLEAR clears the X register and blocks the stacklift, so a new entry overwrites the 0 in the X register.
0..9Digits. May look different if alternative digits are chosen in the Modes dialog
', EEX' or '. EEX'Decimal separator/Enter exponent. Press once to enter decimal separator, twice to enter exponent. How the decimal separator looks depends on the setting in the Modes dialog. The default is a guess based on the country setup of the phone.
'::.'Enter time separator. Depends on setting in the Modes dialog. Hours, minutes and decimal minutes can be entered by pressing the decimal separator key after entering minutes.
<-Move the entry point ('_') to the left
->Move the entry point to the right
BSPDelete to the left of the entry point
RUPRoll the stack up
RDNRoll the stack down
X<->YSwap X and Y registers
CLEARClear X register
ENTERFinish entry of a value or copy the X register
MEMSwitch to memory mode
HISTSwitch to history mode
MODESOpen the modes menu
SYSA menu with operations to clear various things, and an about box.
BackReturn from menus or from memory/history mode
UNDOUndo an operation. The undo buffer has room for several hundred operations. Undone operations are added to the redo buffer.
REDORedo next undone operation
Register operations
STOStore value in current register
RCLRecall current register or history value
X<->RSwap X register and current register
CHSChange sign
RMDRemainder. For negative arguments, this operation may return negative results, unlike the mathematical modulus operator.
SQRTSquare root
INTInteger part
Conversion operations
These operations work as on the HP32SII and HP33S calculators. They convert the value in the X register to another unit. The Temperature conversions convert absolute temperatures.
->kgPound to kg
->lbKg to pound
->FCelcius to Fahrenheit
->CFahrenheit to Celcius
->cmInch to cm
->inCm to inch
->lGallons to liter
->galLiters to gallons
Time operations
The time operations get the current time, or convert between time and decimal hours, minutes or seconds. If the X register is a time value, it is converted to a number, and numbers are converted to time values. Note that conversion from time to hours or minutes may be inexact, because 1/60 cannot be represented exactly as a decimal number.
HOURConvert time to decimal hours or vice versa
MINUTEConvert time to decimal minutes or vice versa
SECONDConvert time to decinal seconds or vice versa
TIMEGet current time as a time value.

Error messages

Invalid entryThe digit or separator was not accepted because the value would not be valid (too big etc.)
OverflowThe result is larger than 1E100
Divide by 0The result of a division is infinite
Division undefined0 / 0 has no result
Domain errorSquare root of a negative number etc.
Quantization errorQuantization not possible
Invalid operationOther invalid operation

Status line

Stack view:

Inexact'~' is shown if the last result is inexact (e.g. 1/9 = 0.111...)
Angle modeDEG or RAD is shown depending on the angle mode
OperationThe last operation executed, or preview of the next operation

Memory view:

PositionCurrent position (0-99)
OperationThe last operation executed, or preview of the next operation

Argument history view:

ViewARGS or ARGM (argument history to memory)
PositionCurrent position (from 0 to depth - 1)
DepthDepth of argument history (0-99)
OperationThe last operation executed, or preview of the next operation


Stak is written by Gunnar Degnbol. Comments and bug reports are welcome at

gdegnbol at tiscali dot dk