inlineLogoBlack

ThetaCalc

Version 1.6

ThetaCalc is an iOS app for the iPhone and the iPad. It is an RPN calculator which can be programmed by the user in JavaScript. It is available for free on the App Store.

Privacy Policy

This app does not collect any kind of personal data of the user. It does not store any personal data nor does it make such data available to third party.

Reverse Polish Notation


The calculator uses Reverse Polish Notation (RPN, with 4 stack levels) as its input mode. Here are some examples:

To calculate '2 + 7' press

2ENTER7+

To calculate '8 x (9 - 3)' press

8ENTER9ENTER3-x

To enter a negative number, press +/-, e.g. to enter '-5' press

5+/-

Math Panel: Standard Math Functions


The Math panel contains the usual math functions and the following special functions:

hr converts from h.mmss to decimally specified hours, minutes and seconds
hms converts from decimally specified hours, minutes and seconds to h:mmss
hms+ adds two h.mmss values
comb calculates combinations (y x)
perm calculates permutations (y x)

Func Panel: User Defined Functions


In the Func panel you can add new functions and select existing functions for running,deleting, duplicating, editing or assigning. An indicator to the left of the function name shows it's type (see below).

Types of functions

F
Prompted functions define up to 5 parameter definitions, each consisting of a prompt and a variable name. When such a function is run, the user can first enter values for the parameters and then execute the function. Prompted functions should return 1 to 4 numeric values which are set as values for the calculator stack registers (see below for more details).
A
Assignable functions do not have prompted parameters. These functions can be assigned to buttons in the User panel. Assignable functions should return 1 to 4 numeric values which are set as values for the calculator stack registers (see below for more details).
P
Programs can have prompted parameters. They can return arbitrary text content as output (see below for more details).
E
Equations implement formulas which can be solved for any of their up to 5 prompted parameters.

User Panel: Assigned Functions


The User panel holds up to 10 user defined functions. To assign a function to this panel you first select an assignable function in the Func panel, then change to the User panel, press 'Assign' and select the button which should refer to this function.

Edit Program Description


In the 'Desc' tab you can provide a description of the function.

Edit JavaScript Source


Edit your JavaScript program or function using the built-in editor.

Define Function Arguments


Functions of type prompted can have up to 5 parameters.

Execute Function or Program


Provide the parameters and then execute the function.

Execute Equation


Enter parameters and indicate unknown parameter, then solve for the unknown.

Equation Description


Equation Code


Equation Parameters


Base Panel: Base Conversions


The Base panel allows conversions between different number bases. In addition, bit shift and logical operations can be performed.

Only the X and Y registers are displayed (now in the same size in order to make masking operations easier), however, all 4 stack registers are still present.

In signed modes the leftmost bit is interpreted as the sign bit and accordingly represented in decimal mode. The sign bit is not preserved by any operations or word size changes and might be set when an overflow occurs. Changing from a longer word size to a shorter one simply cuts off the leading bits.

Units Panel: Unit Conversions


The Units panel allows conversions between different units of the following categories:

A
Area
L
Length
V
Volume
M
Mass

First select the unit to convert from in the left table, then the unit to convert to in the right table. The value to to be converted and the result are taken from / written to the X register.

Const Panel: Numeric Constants


The Const panel holds named definitions of numeric constants.

Settings Panel


Help


Programming


All programming is done using the JavaScript language. Before a user defined function is executed, it is embedded in a template which provides definitions of the parameters as well as a number of predefined functions.

Accessing Parameters

For each prompted parameter a corresponding JavaScript variable will be generated. For instance if you define a parameter with the prompt 'Iterations' and the corresponding variable 'n' and the users enters the value '1000' for this parameter when running the function, then the following line will be inserted in the template:

let n = 1000;

If a parameter has multiple parts separated by comma, then corresponding variables will be generated for all parts.

Accessing the Stack

The stack values can be accessed (read only) by using the predefined values for the x, y, z and t registers, e.g.:

let x = _x;

Setting Return Values

Prompted functions and assignable functions must only return 1 to 4 numeric values as their result. After such a function returns, the calculator stack is modified using these values. To return a single value v, which is to become the new x value use:

return v;

To set the x and y registers from your variables v and u use:

return v + ':' + u;

or, alternatively:

return `${v}:${u}`;

Programs can output any content by directly appending to the predefined _output variable or by using one of the print functions (see below). They cannot, however, modify the stack by returning values. After the body of the program a return of the _output variable is automatically inserted by the template.

Equations must return an expression which is then compared to zero during the solving process. E.g. the motion formula s = v * t should be implemented as follows:

return s - v * t;

Predefined Functions

The following trigonometric functions calculate their results corresponding to the currently set angular mode of the calculator:

sin(x) cos(x) tan(x)

asin(x) acos(x) atan(x)

The following functions start and stop a timer using a predefined _timer variable:

startTimer()

stopTimer()

To format a number n using a field of width w and d decimal digits, use the function:

format(n, w, d)

The following functions append to the _output variable.

Simple append:

print(s)

Append with newline:

println(s)

Append elapsed time with newline:

printlnElapsed()