Git Product home page Git Product logo

Comments (3)

gjf2a avatar gjf2a commented on June 25, 2024

from bare_metal_modulo.

gjf2a avatar gjf2a commented on June 25, 2024

I have thought of a way to implement this. It needs to take into account the original dividend. All operations ultimately funnel down to a call to .with(), which will actually perform the modulo. So I think the solution is to introduce a new data type that tracks the total "wraparounds" it has experienced. I just finished a major refactoring of the crate that will facilitate adding new data types.

So, to do this:

  • Create a WrapTrackNum that keeps track of wrapping and implements the MNum trait.
    • It will have a state variable that tracks the total wrap count that occurred when it was created.
  • Then invoke the derive_modulo_arithmetic! macro to generate all the arithmetic operator implementations.

from bare_metal_modulo.

gjf2a avatar gjf2a commented on June 25, 2024

Thanks again for the suggestion, @linclelinkpart5! I have now implemented it as follows:

  • WrapCountNum and WrapCountNumC are drop-in replacements for ModNum and ModNumC that each have a wraps() method.
  • That method returns accumulated wraparounds as defined above.
  • See the documentation for a full illustration of how they work.

Due to the delay between this implementation and when you posted the issue, it may or may not be useful to you at this point, but I am guessing that your suggestion indicates something that would be useful to many people, so I am pleased that I was finally able to incorporate it.

from bare_metal_modulo.

Related Issues (9)

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.