% acts as a remainder operator and not a modulo operator
rv3r opened this issue ยท 3 comments
The % operator, according to the docs, return the modulus of a number. However, given that the example -9 % 4 => -1
is shown in the docs, it appears to be acting as a remainder operator similar to what it does in Java. This is confirmed by in-game testing.
I can think of three possible ways to amend this.
- (easiest) Rename it to 'remainder operator' in the docs.
- (more work to fix, but my preference) Make it function like a modulus operator:
-9 % 4 => 3
- (worst option) Have two separate operators, one for remainder and the other for modulus
I am in favour of no. 2 as well. Will change the semantics, but I doubt if Java's reminder has any use for anybody.
Yeah i agree, never needed remainder functionality, so for cases where i needed modulos and negative values matter, i always had to do something like mod(x,y) -> (x%y+y)%y
to make it work as modulos