Giter VIP home page Giter VIP logo

Comments (2)

mszyca avatar mszyca commented on July 30, 2024

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.

mszyca avatar mszyca commented on July 30, 2024

(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)

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.