Coder Social home page Coder Social logo

Comments (4)

simonbyrne avatar simonbyrne commented on September 15, 2024

I'm far from an expert on these things, having only really discovered this by a similar accident, but as I understand it rounding modes typically are only correct for basic arithmetic operation (and sqrt). There is CRlibm, which claims to be much more accurate for these cases, but even then at some point you still suffer from the table-maker's dilemma for any operation involving transcendental numbers.

This should be documented though.

from openlibm.

simonbyrne avatar simonbyrne commented on September 15, 2024

Or alternatively, we could save and restore the rounding mode, doing the actual computation in round-to-nearest, which I understand is what glibc does.

from openlibm.

StefanKarpinski avatar StefanKarpinski commented on September 15, 2024

I think that saving and restoring is probably the best approach. The main use case for changing rounding modes is verifying algorithm stability, which doesn't really work if our libm functions return garbage – testing their algorithm stability is not the point – they are one of the few things in the system that we actually know are really stable across the full range of values. The real trick is going back to default rounding in libm without a big performance hit.

from openlibm.

stephentyrone avatar stephentyrone commented on September 15, 2024

@simonbyrne I wouldn't expect openlibm to deliver correctly rounded results (we have CRlibm for that), but a high-quality math library should at the very least satisfy a small (in ULPs) error bound regardless of the prevailing rounding mode -- ideally less than an ULP.

@StefanKarpinski That's undoubtedly the simplest fix. In the long run, if someone gets ambitious they may want to investigate doing argument reduction using integer operations (on 64-bit platforms this can actually be quite efficient, and they are of course not effected by rounding mode).

from openlibm.

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.