vatbub / mathevaluator Goto Github PK
View Code? Open in Web Editor NEWA simple java based math expression parser
License: Apache License 2.0
A simple java based math expression parser
License: Apache License 2.0
Expected output:
7--3 = 7+3 = 10
Console output:
7--3
java.lang.ClassCastException: com.github.vatbub.mathevaluator.OperatorImplementations$SubtractOperator cannot be cast to com.github.vatbub.mathevaluator.Number
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:333)
at com.github.vatbub.mathevaluator.sample.Main.main(Main.java:45)
Please enter your math expression (Hit Ctrl+C or type 'exit' to quit the program) [default: exit]:
7++6
java.lang.ClassCastException: com.github.vatbub.mathevaluator.OperatorImplementations$AddOperator cannot be cast to com.github.vatbub.mathevaluator.Number
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:333)
at com.github.vatbub.mathevaluator.sample.Main.main(Main.java:45)
Expected output:
IllegalArgumentException: Circular reference detected
Console output:
Please enter your math expression (Hit Ctrl+C or type 'exit' to quit the program) [default: exit]:
r = r + 1
Exception in thread "main" java.lang.StackOverflowError
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:275)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:288)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:288)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:288)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:288)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
at com.github.vatbub.mathevaluator.MathExpression.evaluate(MathExpression.java:288)
at com.github.vatbub.mathevaluator.RuntimeConstant.getValue(RuntimeConstant.java:37)
Hy,
I'm making this expression:
3.93 + 2.87 + 2.23 + 2.51 + 2.05 + 2+2.65 + 2.66 + 2.6 + 2.6 + 2.6 + 2.6 + 1.9 + 2.6 + 2.6
The result shoud be: 38.4
But I'm getting when running with the MathExpression as result: 38.400000000000006
Here the simple code:
MathExpression expression = new MathExpression("3.93+2.87+2.23+2.51+2.05+2+2.65+2.66+2.6+2.6+2.6+2.6+1.9+2.6+2.6"); System.out.println("expression.value = " + expression.evaluate().getValue());
Is this a bug in your library or what is here wrong?
Thanks,
Tom
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.