Git Product home page Git Product logo

bare_metal_modulo's People

Contributors

gjf2a avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

bare_metal_modulo's Issues

Count number of "wraps" when adding to `ModNum*`

I've found myself in need of a library like this, and it fulfills almost all of my uses! However, I also need to count how many times the modulated value is wrapped around the modulus when performing an addition. For example, if I have 8 mod 17, and add 42 to it, I'd get the usual 16 mod 17, along with a 2 to indicate that the modulated value wrapped around the modulus twice.

I'm happy to add this functionality myself and make a PR, but wanted to get feedback beforehand. Namely, I'd love some advice on what to name this method.

OffsetNumC: signage?

Assess whether OffsetNumC ought to work with signed values only. If so, enforce this at the type level.

Inequalities

Currently, inequalities between a ModNum and a regular integer compare .a() against the integer value.

Would it be better to compare against the integer (mod m)? Currently, my doc test demonstrates the former comparison. This would be a backwards-incompatible change.

I need to think this over.

Create PowSigned and PowAssign traits.

Currently, the Pow trait allows the .pow() operator to be overloaded for both raw numbers as well as modular numbers. I would like to introduce similar PowSigned and PowAssigned traits to enable the same treatment for .pow_signed() and pow_assign(), which at the moment are only defined for raw number rhs arguments.

This isn't hugely important, because one can always use .a() to transform the right-hand side. But it would make these methods consistent with how everything else in the crate works.

Add .pow() and .pow_signed() to WrapCountNum and WrapCountNumC

I didn't yet implement .pow() for WrapCountNum and WrapCountNumC, as tracking the wraps would significantly disrupt the current implementation. But I would still like to do this. It will require creating a separate implementation from the current one that is engineered to track the wraparounds as the multiplications and additions occur.

Document and enhance OffsetNumC

OffsetNumC needs documentation tests. It also needs a ModNumIterator implementation and methods to return its minimum and maximum values.

Unexpected but possibly intentional behavior with `OffsetNum`

Hi, finding this crate very useful, but I discovered an unexpected, or non-intuitive behavior with the way OffsetNum arithmetic works. Consider the following:

let x = OffsetNum::new(3, 10, 1);

println!("{:?} {}", x, x.a());
let y = x - 1;
println!("{:?} {}", y, y.a());

This results in:

OffsetNum { num: 2, modulo: 10, offset: 1 } 3
OffsetNum { num: 2, modulo: 10, offset: 1 } 3

whereas I would have expected:

OffsetNum { num: 2, modulo: 10, offset: 1 } 3
OffsetNum { num: 1, modulo: 10, offset: 1 } 2

That is, I would have expected arithmetic with integers to always be relative regardless of the offset. After some experimentation, it seems that the integer is first being converted to OffsetNum::new(1, 10, 1), which is equivalent to 0 due to the offset so that the subtraction has no effect. It is obvious how I can accomplish what I want, but is this the intended behavior or an oversight due to just simply doing the obvious conversion before the subtraction?

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.