Menu

#46 Modulo bug due to internal multiplication (from GIMP repo)

open
nobody
bug (2) easy (2)
3
2020-09-29
2020-09-29
No

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.

Discussion

  • Kevin Cozens

    Kevin Cozens - 2020-09-29

    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.

     
  • Rodion Gorkovenko

    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.

     

Log in to post a comment.