MNI Integer Calculator (MIC)

The MNI Integer Calculator MIC.

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.

The MNI Integer Calculator MIC is an implementation of the functionality of M4's eval in Java.

Usage

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 %

Grammar and Operators in mic

Expression comprise integer literals like "3", parenthesis "(" and ")" and the following operators

Unary Operators

+ Plus sign
- Minus sign
~ Bitwise negation
! Logical negation
Binary Operators
PrecedenceOperatorMeaningAssociativity
high** Powerright
* Multiplicationleft
/ Divisionleft
% Moduloleft
+ Additionleft
- Substractionleft
<< Left shiftleft
>> Right shiftleft
< Less thanleft
> Greater thanleft
<= Less or equalleft
>= Greater or equalleft
== Equalleft
!= Not equalleft
& Bitwise andleft
^ Bitwise xorleft
| Bitwise orleft
&& Logical andleft
low|| Logical orleft