This calculator has a very simple window, but can do a lot of math. The expression must be typed in, the advantage with this is that they can be modified or corrected easily and the expression is saved on a list and can be reused.

Numeric display format

Input line

Output

Input number and text format

Operators

Variables

Scripting

Functions

Main page

Numeric display format

The calculator can display in multiple formats:

- SI: Use SI prefix after the numbers (pnumkMGT).
- EE: Use exponent notation (1E5) when number is a bit large or small.
- 4 & 9: Use up to this amount of digits after the decimal point, will use exponent notation for large numbers, but not for small numbers (They are shown as 0).
- Int: Do not show decimals.
- Str: Use the default format for the value, the other formats will fall back to this format for values they cannot handle.
- HEX: Show number in hexadecimal, it will also show strings as a list of hex values.
- BIN: Show number in binary.

Input line

All expressions is written on the input line and calculated when "ENTER" is pressed. If the field gets red there is something wrong with the expression.

All successful expressions are saved and can be found by clicking the black triangle.

Output

Output is shown on the line above the input line.

A more a advanced function may have more advanced output, here I show two different format options.

Right clicking opens a menu where the output can be copied to the clipboard or copied to the main log window in TestController.

Input number and text format

The numeric input in the calculator is very flexible in handling different formats:

- 123: A plain number, this is an integer.
- 123.456: A plain number, this is a floating point number.
- 34.56e12: Using exponent notation for large or small numbers.
- 34n: It is also possible to use SI notation for large and small numbers.
- 17ki: Use binary SI notation when calculating on memory or disk space for computers.
- 4i or 4j: Complex numbers, can be combined with exponent or SI notation (Binary SI notation take precedence)
- 0xaa or aah: Hex notation
- 0b1101 or 1101b: Binary notation

- Binary SI & complex with i: The binary SI prefix take precedence for kMGTPEZY SI prefix.
- E: it can be either exponent notation (i.e. 1E4) or SI prefix. It will be exponent notation if there is a number or +/- next to it, in all other cases it will be SI prefix (i.e. a space after the E secures it is a SI prefix), using a lower case e will always be exponent notation.

Using "text" will create a text string. String supports a couple of escape codes: \" \\ \r \n \t \b \xXX \uXXXX

The X must be replace with hex digits.

A text string containing a number will automatic be converted to a number if needed. This means "123"+1 is legal and will return 124

The conversion of text strings to numbers is simpler than above and do not support any SI prefixes

Operators

The operators mostly matches C and Java operators. The operators are:

- & | ^ >> <<: Binary operation on integer: and or xor rightShift leftShift
- * / %: Multiplying operators: multiply divide modulus
- + -: Additive operators: add subtract
- < > <= >= == !=: Comparative operators: less, greater, lessEqual greaterEqual equal notEqual
- && ||: Logical operators: and or
- ?:: This operator is a if statement by itself: condition?trueValue:falseValue it may need parentheses around it.

Before a number it is possible to use one of:

- -: Negate the value.
- +: Do nothing.
- !: Flip the boolean value.
- ~: Flip all the bits.

Variables

It is possible to create variables and use them in expressions.

Code:

VAR name GLOBALVAR name VAR name = value GLOBALVAR name = value

The GLOBAL version will make the variable available anywhere in TestController where an expression can be used, the plain VAR version is only accessible in the calculator.

One way to use VAR is when the same value is used multiple times:

var f=10k;cpxToCLRs(f,par(cpxC(f,3u),cpxL(f,50u),cpxR(100)))

In the above expression I can easily change the f value and redo the calculation.

Scripting

This popup can be controlled with:

#SHOWPOPUPSYSTEM Calculator {x y {w h}}

#CLOSEALL

Any scripting line starting with a equal sign = is passed to a instance of the calculator engine. This means GLOBALVAR is shared between them, but not VAR. Anything within parentheses on a scripting line is also handled by an instance of the calculator.