Comments (3)
Hey Tom, the library saves number literals as double
s, the calculations are hence carried out using double precision. To me, this looks like usual rounding errors which occur when doing floating point calculations. I will have a closer look at it later today.
from mathevaluator.
I just tried your example and modified it a little:
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");
double expected = 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;
Number result = expression.evaluate();
System.out.println("expression.value = " + result.getValue());
System.out.println("expected result: = " + expected);
I got the following console output:
expression.value = 38.400000000000006
expected result: = 38.400000000000006
This shows again that the issue is rounding related to floating point rounding errors. If you wish to read more about why this happens, you can read this overview on StackExchange or this paper if you wish to get more in-depth information.
Let me know if you need any other help with the library :)
from mathevaluator.
Apart from that, you may want to pull and run mvn install
again as I just fixed issues #1 and #2 .
Cheers :)
from mathevaluator.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathevaluator.