saxbophone / arby

Arbitrary precision arithmetic in C++, even at compile-time
https://saxbophone.com/arby/
Mozilla Public License 2.0
8 stars 1 forks source link

Division<T> type for representing result of division with remainder #137

Closed saxbophone closed 1 year ago

saxbophone commented 1 year ago

We can call the members quotient and remainder.

We can also provide some kind of way to convert a division result to an Interval<T>, probably as either a cast operator, to_interval() method or using a converting constructor of Interval<T>.

Also should provide a templated converting constructor for converting from instances of this template on other types, so we can take advantage of say automatic casting from Nat <-> Int without needing to special-case them.

This should naturally, support the same tuple item-getter interface of std::pair and std::tuple, so we can still use our replacement type with structured bindings. With this in mind, we would do best to not change our existing tests to use Division explicitly, and instead keep the structured bindings usage: https://stackoverflow.com/a/37188019/6177253

Depends on #136

saxbophone commented 1 year ago

Consider custom std::cout output as quotient and remainder, e.g. 9r2

saxbophone commented 1 year ago

Here's some helpful info on how to support the same interface that tuple/pair use: https://dominikberner.ch/structured-bindings/

saxbophone commented 1 year ago

should also support converting to Interval<T> for ceiling and floor