GithubHelp home page GithubHelp logo

Comments (2)

clyring avatar clyring commented on July 3, 2024

What should the result of formatDouble (standard places) be when it is the same distance to round up or down?

Rounding to even is the usual expected behavior when it really is the same distance to round up or down. But my point is that:

  • There is no value of type Double which exactly represents 12.345.
  • 12.345 :: Double therefore means the closest representable Double to the real number 12.345, which happens to be 0x1.8b0a3d70a3d71p3 and represents the rational number 6949617174986097 % 562949953421312.
  • This rational number is greater than 12.345, by approximately 6.4e-16, and is thus slightly closer to 12.35 than it is to 12.34.

Both base and bytestring have the same bug, and first round 0x1.8b0a3d70a3d71p3 to the minimum number of decimal digits needed to disambiguate it from its neighboring Doubles and only then round that intermediate result to two decimal digits, when the user has asked 0x1.8b0a3d70a3d71p3 to be rounded directly to two decimal digits.

from bytestring.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on July 3, 2024

Seems like the choice is to have compatibility with base or be more correct.

from bytestring.

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.