## Numbers

Enter numbers using the number buttons (keys 0–9), decimal point (key ‘.’), and plus and minus buttons (keys ‘+’ and ‘-’). In hexadecimal mode, buttons for A–F become available (keys A–F).

You can enter numbers in exponential notation using the e button (key ‘e’). For example, you can enter −200 as −2.0e2 and 0.032 as 3.2e−2.

For complex numbers the i button (key ‘j’) is useful. The calculator will accept expressions like 3+4i, 4i+3 or 3+i4 (all equivalent). Putting in expressions in complex polar notation is a little harder, but you can use the exp function. For example, you can enter 3+4i as 5exp 0.927295218i.

Note that in polar complex notation, arguments are always in radians, even if the calculator is set to degrees.

### Notation

You can change the output notation of the calculator at any time. You can toggle three types of notation: standard/scientific, rectangular/polar and non-complex/complex. To toggle one of these use shift followed by Sci, Pol or Cplx (keys ‘S’, ‘o’ and ‘z’). Polar notation is only meaningful for complex numbers with nonzero argument (almost always equivalent to nonzero imaginary part). Complex notation forces an imaginary part or argument (when in polar notation) to be displayed even when the imaginary part is zero. The default setting is to show numbers in standard format unless they are too near or far from zero to be displayed accurately, when scientific notation must be used. Imaginary parts and arguments are not displayed if they are zero and if they are then the default format is rectangular.

### Bases

Using the shift button followed by Hex, Dec, Oct or Bin (keys ‘H’, ‘B’, ‘D’ and ‘O’) you can change the base used for input and output. In hexadecimal mode the keys A–F become available and in hexadecimal, octal and binary modes, some functions become unavailable and replaced with logic functions. In binary and octal modes, some of the number keys are disabled.

You can change base at any time. This allows easy conversion between bases. However, only one base is possible for each number in the input display. If you try to change base before you finish a calculation, the calculator will try to evaluate the expression in the current base before displaying the result in the new one.

The way the ‘e’ button works changes according to the base in a natural way. The expression xey always evaluates to x × by where b is the current base. So 1e2 always evaluates to 100 in the current base, but if you convert to decimal the result becomes 4096, 512 or 4 according as the base is 16 (hexadecimal), 8 (octal) or 2 (binary).

Scientific output format works similarly. For example, 1 × 102 in hexadecimal would be represented as 4.096 × 103 in decimal because the ‘10’ represents the base in its own notation. The exception to this is binary notation, where the base is represented as 2 and the exponent as a decimal. This is not ideal, but if the calculator did not do this, there would not be enough space to show some binary representations of results.

### Internal representation

Internally, all numbers are represented as complex numbers whose real and imaginary parts are double-precision floating-point numbers in 64-bit ieee-754 format.

## Arithmetic

The calculator supports the usual four arithmetic operations: multiplication: × button (key ‘*’); division: ÷ button (key ‘/’); adition: + button (key ‘+’); subtraction: − button (key ‘-’). It also supports parentheses ‘(’ and ‘)’, which may be nested to any depth. Note that + and − can also be interpreted as unary identity and negate functions depending on context. For example +2 = 2, 4−−2 = 6 and +−+1 = −1. The calculator should interpret + or − unambiguously from its context; so in contrast to some calculators, you need not worry about meaning.

### Order of evaluation

Calculations are evaluated in conventional order. This should cause no surprises to anyone familiar with standard mathematical calculations.

Calculations are evaluated as follows. While there are any parentheses, each subexpression within a single pair of parentheses is evaluated and replaced with its result. The order of evaluation of expressions without parentheses is:

1. Functions that take a single argument on the left (like the inverse function)
2. Functions that take a two arguments, one on the left, one on the right (like the power function)
3. Functions that take a single argument on the right (like the root function)
4. Multiplication and division
The details of the method of evaluating (parsing) input expressions are in the `Parser.java` file. Thes may be of interest if you want to extend or use its class. It is the class that does nearly all the work of the calculator.