GithubHelp home page GithubHelp logo

Comments (3)

LorkScorguar avatar LorkScorguar commented on August 10, 2024

I also have this issue on latest calculator app. It seems that most calculator apps have this issue, even Google.
15 numbers is the max precision we can get

from calculator.

michallepicki avatar michallepicki commented on August 10, 2024

Recently Microsoft open-sourced their calcuator app, and inside we can find a library that allows for

infinite precision for basic operations (addition, subtraction, multiplication, division) and 32 digits of precision for advanced operations (square root, transcendental operators)

The calculator is written in C++ but glancing over the library I think it's using only C so it should be possible to use it relatively easily.

from calculator.

 avatar commented on August 10, 2024

Another example:
12345679 * 12345679 * 81 = 12345678987654320, but it was expected 12345678987654321.

The problem is that the built-in data type, double, is used for calculations. The built-in types are good for software calculations like iterations over the transition matrix, when a range of values ​​is known. But to use them for working with user data, when the range is obviously unknown and accuracy is important at the output, is bad practice.

The solution is quite simple: use third-party data types for calculations using long arithmetic.
Like MPRF (Examples of good calculators you can see there in "Software Using MPFR")

https://en.wikipedia.org/wiki/List_of_arbitrary-precision_arithmetic_software

For Vala there is a building to libgcrypt: https://gitlab.gnome.org/GNOME/vala-extra-vapis/blob/master/gcrypt.vapi
See MPI

Or see https://github.com/GNOME/gnome-calculator/tree/master/vapi

from calculator.

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.