Comments (3)
from bare_metal_modulo.
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 theMNum
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.
Thanks again for the suggestion, @linclelinkpart5! I have now implemented it as follows:
WrapCountNum
andWrapCountNumC
are drop-in replacements forModNum
andModNumC
that each have awraps()
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)
- Add .pow() and .pow_signed() to WrapCountNum and WrapCountNumC HOT 1
- Create PowSigned and PowAssign traits.
- Relax Signed constraint on wrapping int subtraction
- Document and enhance OffsetNumC HOT 1
- OffsetNumC: signage?
- Bug in OffsetNum equality comparison
- Inequalities
- Unexpected but possibly intentional behavior with `OffsetNum` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bare_metal_modulo.