In version 4.1.60 of GAWK the div() function returns remainders that seem
wrong, or at least inconsistent with the standard mod (%) function.
This only happens with negative numerators. Programming languages
vary on the proper way to deal with this, so I'm not going to suggest
that one calculation or the other is correct. However the behavior
for bignums and regular integers should at least be the same.
Here's a demo of the problem:
Running this program (remainder.awk):
--------------------------------------------------------------------
BEGIN {
test(15,7)
test(-15,7)
test(15,-7)
test(-15,-7)
}