Screenshots |
|
Calc7 | Source Code |
|
|
Calc7 is the Seed7 calculator. It works like a read-eval-print loop (REPL). Calc7 is interactive program that reads single expressions, evaluates them and writes the results. Calc7 can be called from a command window with: s7 calc7 Calc7 requests user input with the prompt: calculate? The user can enter an expression (on this page user input is displayed in green):
calculate? 1+2*3
Pressing Return (or Enter) starts the evaluation. Calc7 responds with the result: 7 The commands quit and exit can be used to leave calc7. An input line can be edited with the following keys:
Calc7 accepts arbitrary complex Seed7 expressions:
calculate? length(str(-((1+2)*4)**12))
14
The expressions can use the types boolean, integer, bigInteger, rational, bigRational, float, complex, char, string, array, hash, set, time and duration: calculate? 2 + 2 >= 2 * 2 TRUE calculate? "hi" mult 5 hihihihihi calculate? 2.5**2 6.25 calculate? 1/19 0.(052631578947368421) calculate? time(NOW) 2014-07-30 12:56:13.915252 UTC+2 (DST) Syntax errors are shown as follows:
calculate? "abc
*** STRING(17):25: String literal exceeds source line
writeln("abc);
--------------------^
*** STRING(18):46: ")" expected found "exception"
exception
-------------^
*** 2 errors found
Computation errors are shown with the name of the exception:
calculate? 1 div 0
NUMERIC_ERROR
If the result of an integer expression is too big or too small the exception OVERFLOW_ERROR is raised:
calculate? 4000000000 * 3000000000
OVERFLOW_ERROR
To avoid an overflow the computation can be done with bigInteger:
calculate? 4000000000_ * 3000000000_
12000000000000000000
|
|
|
|
|