Wire Modulo Node giving incorrect value for negative inputs

Post your questions here and we'll all try to help.
Post Reply
samTrolland
Met Resolume in a bar the other day
Posts: 7
Joined: Fri Oct 14, 2022 07:15

Wire Modulo Node giving incorrect value for negative inputs

Post by samTrolland »

It looks like the Wire node 'Modulo' gives incorrect values for negative numerator inputs.

Example according to Wolfram Alpha:
11 mod 7 = 4
-11 mod 7 = 3

In Wire:
11 mod 7 = 4 (correct)
-11 mod 7 = -4 (incorrect)
Screen Shot 2023-02-15 at 5.20.44 pm.png
Screen Shot 2023-02-15 at 5.19.13 pm.png
Screen Shot 2023-02-15 at 5.19.13 pm.png (8.56 KiB) Viewed 535 times
Screen Shot 2023-02-15 at 5.20.30 pm.png
Screen Shot 2023-02-15 at 5.19.33 pm.png
Screen Shot 2023-02-15 at 5.19.33 pm.png (8.29 KiB) Viewed 535 times

samTrolland
Met Resolume in a bar the other day
Posts: 7
Joined: Fri Oct 14, 2022 07:15

Re: Wire Modulo Node giving incorrect value for negative inputs

Post by samTrolland »

The correct Modulo result for negative inputs can be achieved in Wire using a few extra logic nodes:

If the Modulo Result is less than 0 then add the denominator to the result.

-11 mod 7 = 3 (correct)
Screen Shot 2023-02-15 at 6.11.31 pm.png
11 mod 7 = 4 (correct)
Screen Shot 2023-02-15 at 6.11.42 pm.png

Zoltán
Team Resolume
Posts: 7088
Joined: Thu Jan 09, 2014 13:08
Location: Székesfehérvár, Hungary

Re: Wire Modulo Node giving incorrect value for negative inputs

Post by Zoltán »

There are some ways to do mod, looks like wolfram does a different one than Wire.
If you try the same in Processing you get the same result as in Wire.
Software developer, Sound Engineer,
Control Your show with ”Enter” - multiple Resolume servers at once - SMPTE/MTC column launch
try for free: http://programs.palffyzoltan.hu

Post Reply