This is apropos numpy#6127. The fix is to make the functions floor_division
and remainder consistent, i.e.,
b * floor_division(a, b) + remainder(a, b) == a
Previous to this fix remainder was computed a the C level using the '%'
operator, and the result was not always consistent with the floor
function. The current approach is to compute the remainder using
b * (a/b - floor(a/b))
which is both consistent with the Python '%' operator and numerically
consistent with floor_division implemented using the floor function.
Closes numpy#6127.
Fix the remainder function so that it is consistent with floor_division.
Instead of using the C % operator, this PR computes remainder(a, b) as
which is consistent with implementing floor_division(a, b) as floor(a/b) and numerically better behaved than the implementation
Closes #6127.