Eval: command line and console calculator.
File Eval_Code.zip contains source code for the program.
eval.zip contains binary for windows.
concalc.tar.gz contains binary for Linux.
Building from sources.
The program is written in Free Pascal and can be built either with Lazarus or
with a Free Pascal text.mode IDE. It uses LMath library and CRTExt unit from
NVUtils package.
Sources of these libraries are included together with the sourse of
eval. To build the program from sourse, first compile these packages,
then the program itself.
Installing
Windows.
Unpack and copy eval.exe and eval.txt to a location of your preference.
Linux.
Linux version is called concalc to avoid name conflict with built-in eval
command. Correspondingly, in all examples below, in Linux write concalc
instead of eval.
Usage
I. Command line
Command line parameter(s) are interpreted as a mathematical expression.
All spaces are ignored. The expression is evaluated, result is printed in
the console and the program terminates.
Example 1:
c:\>eval sin(3.14159/2) + 1
1.0000
If no command line parameter is present, interactive session is started and
prompt ">" is displayed.
II. Interactive session
Enter an expression to evaluate. Result of evaluation will be
printed out and automatically assigned to "_LAST" variable which may be used
in further calculations.
Example 2:
c:\>eval
Console calculator. Enter expression to evaluate.
Type "help" or "?" to get help; type "exit" or "q" to exit.
> exp(4.5)
90.0171
> x/2
45.0086
> _last
45.0086
Alternatively, you can explicitly assign the result of evaluation to another
variable using ":=" operator.
Variable names can consist of latin letters "A"-"Z", "a"-"z", numbers and
symbol "_".
Variable name cannot begin with a number. It is not recommended to use
names beginning with "_". They are reserved for internal use.
Names are case-insensitive.
Example 3:
> MyVar := 25
25.0000
> a := 30
30.0000
> a+MyVar
55.0000
Assign value to _DECIMAL variable to change number of digits after the decimal
dot. The setting will be preserved for future sessions and command line use.
Example 4:
>_decimal
4.0000
>2+3
5.0000
>_decimal := 6
6.0000
>2+3
5.000000
Type "help" or "?" to get help in a session. Type "q" or "exit" to terminate.
III.Mathematical operators and functions
Operators: +, -, *, /, \ (integer division),% (modulus), ^, ** (exponentiation).
Bitwise: > shift right, < shift left, & and,| or, $ xor, ! not, @ imp, = EQV.
Precedence: !, &, |, $, =, @, ^, * and /, \, %, < and >, + and - .
Parenthesis may be used to override the precedence.');
Following functions are defined (names are case-insensitive).
Elementary functions:
abs(X), Sgn(X), Int(X), Sqrt(X), Exp(X), Ln(X), Log10(X),
Log2(X), Fact(N), Binomial(N,K), Rnd().
Trigonometric functions:
Deg(X), Rad(X), Sin(X), Cos(X), Tan(X),
ArcSin(X), ArcCos(X), ArcTan(X), ArcTan2(X,Y).
Hyperbolic trigonometric functios:
Sinh(X), Cosh(X), Tanh(X), ArcSinh(X), ArcCosh(X), ArcTanh(X).
Special functions:
Gamma(X), IGamma(X), Beta(X,Y), IBeta(A,B,X), Erf(X), LambertW(X)
Probability functions:
PBinom(N,P,K), FBinom(N,P,K), PPoisson(Mu,K), FPoisson(Mu,K),
DExpo(A,X), FExpo(A,X),
DGamma(A,B,X), FGamma(A,B,X), DBeta(A,B,X), FBeta(A,B,X),
DNorm(X), FNorm(X), PNorm(X), InvNorm(X),
DStudent(N,X), FStudent(F,X), PStudent(N,X), InvStudent(N,P),
DKhi2(N,X), FKhi2(N,X), PKhi2(N,X), InvKhi2(N,P)
DSnedecor(N1,N2,X), FSnedekor(N1,N2,X),
PSnedecor(N1,N2,X), InvSnedecor(N1,N2,P)
Examples 5 - 7:
4 * arctan(1) --> 3.1416
sin(0.5)^2 + cos(0.5)^2 --> 1.0000
sinh(0.5)^2 - cosh(0.5)^2 --> -1.0000