Giter Site home page Giter Site logo

Comments (3)

Gip-Gip avatar Gip-Gip commented on July 29, 2024 1

I'll look into experimenting with a few options over the next few days or so. A good .pow function would look something like

fn pow(left: Fraction, right: Fraction) -> Fraction {
    let exp = right.numer().unwrap().clone();
    let root = right.denom().unwrap().clone();
    
    // Insert code here where result = nthroot(left^exponent, root)

    return result
}

from fraction.

dnsl48 avatar dnsl48 commented on July 29, 2024

Hi @Gip-Gip, thank you for your interest and your support!

Regarding pow, I feel like we may consider falling back to num-rational pow implementation. Fraction is built on top of Rational type already, so this may be the eastiest path forward

Not too sure about sqrt. That feels somewhat more challenging. I guess you may have a real-world problem on your hands, so we'd be happy to consider a way that would solve your current challenge.

One of the primary goals of this library is to provide lossless math, so I am not too sure if an approximation would follow that direction. However, if we explicitly call that out in the function name (e.g. sqrt_approx), I think that should be totally alright.

from fraction.

feefladder avatar feefladder commented on July 29, 2024

I've been working on a crate heavily building on top of the fraction crate for exact arithmetic. the relevant code is here
first handle special cases such as infinity or nan, then do the calculation. It's inside match statements, but should be quite copy-pasteable into this crate.

from fraction.

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.