Perhaps it's a typo for
a %% b == ((a % b) + b) % b
Which brings a negative modulus into the range [0, b)
( 4 % 3) == 1 ( 4 %% 3) == 1
(-4 % 3) == -2 ?? (-4 %% 3) == 1 ??
a %% b == (( a % b) + **b** ) % b -4 %% 3 == ((-4 % 3) + 3 ) % 3 -4 %% 3 == (-2 + 3) % 3 -4 %% 3 == 1
PS: Hopefully those are short enough to not die on mobile
Conceptually I prefer looking at them as
a % b = a - trunc(a / b) * b a %% b = a - floor(a / b) * b
I disagree about maintenance: use the right formula and do careful unit testing. Abs isn't a great help here either.
Perhaps it's a typo for
a %% b == ((a % b) + b) % b
Which brings a negative modulus into the range [0, b)