Coder Social home page Coder Social logo

Comments (2)

c3d avatar c3d commented on June 5, 2024

Interesting idea. I wonder if the problem is not what default representation for real, ie should it be binary or decimal. Note that decimal FP has other issues (e.g. correct rounding I believe is more difficult).

from xl.

dumblob avatar dumblob commented on June 5, 2024

I wonder if the problem is not what default representation for real, ie should it be binary or decimal.

I'd definitely go also for decimal FP as I feel it must not be "worse than float". But thinking of it there are at least two ideas to explore:

  1. real could actually be made even closer to mathematical notation used "on a paper" by introducing something like a "variable" decimal FP in a sense that one would choose beforehand how many "true" significant digits incl. zeros (not to be confused with decimal places nor with "usual" significant digits) should be used for output (e.g. a literal 1.500 would have 4 significant digits, 0001.500 would have 4 significant digits, 300 -> 3 sigdigits, 0.000100 -> 7 sigdigits) and internally a higher precision would be used to account for few rounding errors whereas float would stay compatible with IEEE 754 and thus support only _Decimal32 _Decimal64 _Decimal128 variants under the hood.

  2. leave float as binary floating point and make only real into decimal floating point (possibly with the significant digits extension for better user experience and output purposes)

Note that decimal FP has other issues (e.g. correct rounding I believe is more difficult).

Could you be more specific? It still has infinity (actualy many infinities and both negative and positive ones) but otherwise most (if not all) of the issues I know of are basically gone. Actually correct rounding of decimal FP is one of the reasons why decimal FP is being used over binary FP. Feel free to take a look at the "best" library emulating decimal FP to see how rounding is being done (btw. mpdecimal is being used also by Python etc.).

from xl.

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.