Found this fixed in gimp repo, but not here.
modulo
may give surprising results, e.g. (modulo 3000000000 4000000001)
shows 7000000001
(instead of 3000000000
).
Fix is one-line change:
https://gitlab.gnome.org/GNOME/gimp/-/commit/f665e4cfa91facf38970d93f9e8e835e6ea1734d
This seems correct, but due to my limited knowledge of scheme I leave it to be counter-checked by some wiser.
You must be using an old version of TinyScheme and/or GIMP. This was fixed in TinyScheme around 9 years ago in r77. The num_mod() routine in both the SF version of TinyScheme and the version included with GIMP are the same. That gitlab commit is wrong in that the R5RS clearly states the sign of the result is the sign of the second operand.
Kevin, sorry, but there is some mystery. I think I see this in current trunk:
https://sourceforge.net/p/tinyscheme/code/HEAD/tree/trunk/scheme.c#l475
Hm. rev77 is where the bug was introduced. Sorry, I poorly explained. Bug is due to overflow in multiplication, which may give negative with two positive numbers, for example.