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

Fix divmod bug #107

Closed saxbophone closed 2 years ago

saxbophone commented 2 years ago

Helper method get_max_shift() incorrectly just used the digit counts and comparison of first digits when considering whether a value was "bigger" than the other or not, leading it to recommend shifts which were too big and causing the divmod() algorithm to never terminate.

This fix is possibly a little inefficient due to the use of a multiply in the loop that reduces the size of the shift, however it's correct and that's the first concern. Another issue will be opened to explore optimising this later.

Fixes #104