Code Monkey home page Code Monkey logo

mathevaluator's People

Contributors

dependabot-preview[bot] avatar vatbub avatar

Stargazers

 avatar

Watchers

 avatar  avatar

mathevaluator's Issues

Circular variable references cause StackOverflowError

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)

Wrong result for a simple expression

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

Consecutive unary operators cause ClassCastException

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.