Skip to content

ixiDev/MEE

Repository files navigation

MEE

MEE Math Expression Evaluator


Build CI Test CI Release

Examples


Example 1 :

// create a text source from expression string
val source = TextSource("2^(2+6)*5+log(9+7-ln(6+1))")
// create compiler instance
val compiler = ClCompiler()

val result: Double = compiler.compile(source)
println("Result = $result")
Output : 
    Result = 1281.147803

Example 2 :


see sample file

val filePath = "examples/sample.mee" // a simple Math expression script 
val source = FileSource(filePath)
val compiler = ClCompiler()
println("Result = ${compiler.compile(source)}")

For more simples take a look to tests or to Sample programme

Supported symbols

Supported Symbol Explanation
+ Addition Operator eg. 2+3 results 5
- Subtraction Operator eg. 2-3 results -1
/ , ÷ Division operator eg 3/2 results 1.5
× ,* Multiplication Operator eg. 2*3 results 6
( Opening Parenthesis
) Closing Parenthesis
= Assignment variables eg. a = 22;
pi Math constant pi returns 3.14
log logarithmic function with base 10 eg. log 1000 returns 3
ln natural log function with base e eg. ln 2 returns .3010
exp exponential function
^ power operator eg. 2^3 returns 8
sqrt square root of a number eg. 4 returns 2
sin Sine function
cos Cosine function
pi Math constant pi returns 3.14
e Math constant e returns 2.71
tan Tangent function
asin Inverse Sine function
acos Inverse Cosine function
atan Inverse Tangent function
sinh Hyperbolic Sine function
cosh Hyperbolic Cosine function
tanh Hyperbolic Tangent function
asinh Inverse Hyperbolic Sine function
acosh Inverse Hyperbolic Cosine function
atanh Inverse Hyperbolic Tangent function

How to use

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }
}
Step 2. Add the dependency
implementation 'com.github.ixiDev:MEE:$MEE_VERSION'

Replace $MEE_VERSION with last version