BigInt divMod is wrong for negative first argument

Timon Gehr timon.gehr at gmx.ch
Sat Aug 19 06:14:48 UTC 2023


On 8/18/23 18:14, NonNull wrote:
> 
> But the divMod method could be made to do the right thing, and the 
> existing divMod method could be renamed divRem.
> 

So I guess your suggestion is:

divMod(8, 5, div, mod) -> div=1, mod=3
divMod(-8, 5, div, mod) -> div=-2, mod=2
divMod(8, -5, div, mod) -> div=-1, mod=3
divMod(-8, -5, div, mod) -> div=2, mod=2

And then divMod and divRem would have different "div" behavior I guess.


More information about the Digitalmars-d mailing list