View Single Post
Old 07-13-2016, 11:14 PM  
Human being with feelings
ijijn's Avatar
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 479
Default JSFX: % operator behaving strangely with negative numbers


I've just noticed some confusing behaviour when using the % operator on negative numbers in JSFX. The results seem to vary depending on whether you use variables or constants in the expression. Here's an example:

result1 = -301 % 100; // produces -1

a = -301; b = 100;
result2 = a % b;      // produces +1
It appears to do this same thing across a few different Reaper versions and system architectures that I've had a chance to try.
ijijn is offline   Reply With Quote