KeyJ's Calculator is a quite simple desk calculator application, comparable to other stand-alone programmable calculators (HP, Casio, TI, ...).
It's as simple as it could be: Type an mathematical expression (e.g. 5*4
), press ENTER, and you'll get the result (that is, 20
).
Expressions are evaluated just as they would be written down to paper, with correct brackets and operator precedence (see below).
Numbers can be written as simple decimal numbers such as 37
, 23.42
or 1.5482E-4
.
Integer constants can also be written in binary, hexadecimal or octal notation when preceded by a %
(percent), $
(dollar), or &
(ampersand) symbol, respectively. Examples are %101011
(which is 43 decimal), #B0A7
(yields 45223), or &775
(509).
Additionally, there is one predefined constant, Pi
.
Sorted by precedence, from highest to lowest class:
1 ^
Power
2 *
Multiplication
2 /
Division
3 +
Addition
3 -
Subtraction
4 =
Equal -- yields 1 if both sides are aqual, 0 otherwise
4 <
Less than -- yields 1 only if the left side is less than the right side
4 >
Greater than -- yields 1 only if the left side is greater than the right side
5 &
Logical And -- yields 1 only if both sides are nonzero
5 |
Logical Or -- yields 1 only if any of the sides is nonzero
(Note that <=
and >=
do not work!)
The following functions are currently supported by KeyJ's Calculator:
neg(
a)
abs(
a)
sgn(
a)
not(
a)
round(
a)
trunc(
a)
, int(
a)
frac(
a)
sqr(
a)
sqrt(
a)
exp(
a)
ln(
a)
lg(
a)
ld(
a)
deg2rad(
a)
rad2deg(
a)
random(
a)
sin(
a)
, cos(
a)
, tan(
a)
, cot(
a)
, sec(
a)
, csc(
a)
arcsin(
a)
, arccos(
a)
, arctan(
a)
, arccot(
a)
, arcsec(
a)
, arccsc(
a)
sinh(
a)
, cosh(
a)
, tanh(
a)
, coth(
a)
, sech(
a)
, csch(
a)
arcsinh(
a)
, arccosh(
a)
, arctanh(
a)
, arccoth(
a)
, arcsech(
a)
, arccsch(
a)
deg2rad
and rad2deg
if needed.log(
a,
b)
root(
a,
b)
mod(
a,
b)
fmod(
a,
b)
KeyJ's Calculator features a very simple (but somewhat counter-intuitive :) scripting language. Every line entered in the interactive command line is actually executed as a simple single-line script. At the end of any script, the last value assigned to a variable by a calculation statement is written to the console log.
#
, //
or ;
are considered as comments.x^2-4*y+z
) are computed and the result is stored in the special Variable Ans
(Answer), or _
(underscore). The result of computations that lead to mathematical errors (e.g. division by zero, non-positive logarithm, and so on) is zero, but program execution continues. Use the special variable ` (backtick) to check if an operation failed. It contains the value 1 only if the last operation failed, or 0 if it succeeded.:=
ExpressionAns
.a
to z
and are case-insensitive.write
|print
"
String"
write
|print
Expression[:
Length[:
Decimals]]write
|print
hex
|bin
|oct
Expression[:
Length]
write
, as opposed to print
, does not immediately write the line to the console log, but appends it to a line buffer. This way it's possible to write multiple values in a single console line.hex
|bin
|oct
qualifiers write the value as a 32-bit integer value in hexadecimal, binary or octal notation, respectively.input
Variablelabel
Label0
to 9
and a
to z
(case-insensitive, again).goto
Labelif
Condition goto
Labelif
Conditionelse
endif
if
statement only if the condition evaluates to a nonzero value. Otherwise, the else
block is executed, if it exists.skip
Conditionexit