Coder Social home page Coder Social logo

Floating point precision about medici HOT 4 CLOSED

TomKaltz avatar TomKaltz commented on August 13, 2024
Floating point precision

from medici.

Comments (4)

jraede avatar jraede commented on August 13, 2024

It's been a while since I worked on this but I think everything is rounded to the nearest 100th. I'm aware of floating point precision and its faults, however this is a javascript module that uses mongo, neither of which have support for fixed-point numbers like MySQL's decimal, so the point is moot.

from medici.

koresar avatar koresar commented on August 13, 2024

There is literally one place where is could happen - when we calculate total of all transactions. In the new [email protected] the place is guarded by a brave if statement.

Good news is that medici is battle tested (by us). So, pretty sure precision is not an issue as of now.

from medici.

muenzel avatar muenzel commented on August 13, 2024

Thank you for maintaining this lib. I am currently evaluating for production use.
I found the following rounding issue:

image

{ "_id": "5a991a9446fa7c0794a507ab", "accounts": "Income", "credit": 99.8, "debit": 0, "book": "test", "memo": "Something else", "_journal": "5a991a9446fa7c0794a507a9", "datetime": "2018-03-02T09:34:12.100Z", "__v": 0, "approved": true, "voided": false, "timestamp": "2018-03-02T09:34:12.100Z", "account_path": [ "Income" ] }

{ "_id": "5a991a9446fa7c0794a507aa", "accounts": "Assets:Cash", "credit": 0, "debit": 99.9, "_journal": "5a991a9446fa7c0794a507a9", "book": "test", "memo": "Something else", "datetime": "2018-03-02T09:34:12.100Z", "__v": 0, "approved": true, "voided": false, "timestamp": "2018-03-02T09:34:12.100Z", "account_path": [ "Assets", "Cash" ] }

When I try to debit "0" and credit "0.1" then I get the expected error:

Journal is invalid. Total is: 0.01
(node:1940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: INVALID_JOURNAL

Any thoughts on this? And thanks in advance.
Harald

from medici.

koresar avatar koresar commented on August 13, 2024

Would you be able to:

  1. extract the code snippet which reproduces the bug?
  2. and create a new issue for the bug.

That would help us significantly.
Thanks!

from medici.

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.