# CALCULATOR

The Calculator is a mobile whose only purpose is to help you calculate simple mathematical formulae. If you tell it the formula you need to have evaluated, it will tell you the result back.

Example:

```  tell calculator 2 + 3 * 4
The Calculator tells you '14'
```

If you're too tired to type "calculator", "calc" will do just fine.

There is a short help available if you tell it "help" or "?".

The calculator internally works with double floats, so there's a limit to its precision.

If you're interested in details, here's the syntax it understands:

```  expression = factor | factor '+' expression | factor '-' expression
factor     = unary | unary '*' factor | unary '/' factor | unary 'mod' factor
unary      = exp | '-' unary | '+' unary | function unary
exp        = atom | atom '^' unary | atom '**' unary | atom exponent
atom       = number | '(' expression ')' | '|' expression '|'
| fraction | constant

number     = [0-9]*(\.[0-9]+)?([eE][+-]?[0-9]+)?
fraction   = [0-9]*[¼½¾]         (only shows properly if you have latin-1)
exponent   = [°¹²³]+                           -   "   -
```

The only constants available are "pi", "e" and "inf" (or "infinity").

The functions available are sin, cos, tan, asin, acos, atan, ln, exp, log (base 10 logarithm), floor (round down), ceil (round up), trunc (truncate decimals), round (round away from zero), and sqrt.

The calculator can also factorize numbers:

```  tell calculator factor 4711
The Calculator tells you 'The prime factors of 4711 are 7 and 673.'
```