|
|||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
mic.calc | The MNI Integer Calculator MIC is an implementation of the functionality of M4's eval in Java. |
mic.cli | This package provides the command line interface to the MNI Integer Calculator MIC. |
mic.parser | This package contains the classes for the parser of MIC. |
The MNI Integer Calculator MIC is an implementation of the functionality of M4's eval in Java.
MIC can be used as an embedded calculator
// Instantiate mic
Mic mic = new Mic();
// calculate
int result = mic.calculate( "10*5-3" );
// use result
...
There is also a command line interface to MIC
The invocation with arguments gives the result of the computation.
java mic.cli.mic 10 * 5 - 3
47
The invocation without arguments starts mic in interactive mode.
java mic.cli.mic
mic - the MNI integer calculator, rev 1.0
mic - interactiv mode - enter q to quit
mic %
Expression comprise integer literals like "3", parenthesis "(" and ")" and the following operators
+ | Plus sign |
- | Minus sign |
~ | Bitwise negation |
! | Logical negation |
Precedence | Operator | Meaning | Associativity |
high | ** | Power | right |
* | Multiplication | left | |
/ | Division | left | |
% | Modulo | left | |
+ | Addition | left | |
- | Substraction | left | |
<< | Left shift | left | |
>> | Right shift | left | |
< | Less than | left | |
> | Greater than | left | |
<= | Less or equal | left | |
>= | Greater or equal | left | |
== | Equal | left | |
!= | Not equal | left | |
& | Bitwise and | left | |
^ | Bitwise xor | left | |
| | Bitwise or | left | |
&& | Logical and | left | |
low | || | Logical or | left |
|
|||||||
PREV NEXT | FRAMES NO FRAMES |