Happens with versions 0.98 & 0.99, the behaviour of other versions is unknown.
In a function with an interim result, mod() gives wrong results for larger values.
As long as I don't get an error message, I expect the result to be correct.
The wrong results are marked red in the attached example