Comments (2)
Hi
From math point of view it should be 0. I dont have a time to look in code but it looks like data type problem double, float.
Interesting i will test it and check result. Its very good library but need some more work.
from matex.
(a + b - c)
Calculated value from (a+b )0.37+0.31 which gives 0.68 is not equal to c which is 0.68.
Im not php expert but it looks like php is working on bigger floating point precision.
The solution is to change calculate() method. If boths variables are double to use PHP BC Math — BCMath Arbitrary Precision Mathematics library and set probobly max variables preciosion
OR
I found simpler solution (cast to string and then to float and make addition.
Line 181 of calculate() method, replace for:
$value =floatval((string)$value)+ floatval((string)$subTerm);
from matex.
Related Issues (20)
- Code can't handle round brackets in strings
- Example given does't work
- Can't handle negative numbers HOT 1
- Rounding HOT 1
- Custom basic operators HOT 1
- Composer not installing for my PHP version. HOT 3
- Assign a value to a variable inside an expression HOT 3
- Exception: Empty argument in Evaluator->addArgument() when custom function without arguments HOT 4
- Order of operations between powers and multiplications HOT 5
- Support zero float point variables (x =>0.1)
- Double-byte characters such as * are not available
- Could not evaluate "2*0*0.45*0.3*7.4999999999999997E-2"
- Not working with multiples of 10
- Add composer.json and add this to https://packagist.org/ HOT 7
- Make variables case sensitive (not only Lower Case) HOT 3
- Support comparison operators (>, <, =, >=,<=) to get a true / false evaluation HOT 4
- Examples difficult to understand HOT 4
- ( 101.25 + -202.44 ) results in "syntax error"
- Handle invalid operations
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 matex.