mojira.dev
MC-99508

scoreboard operation %= (modulo) not working correctly

When trying to take modulus to a negative number it fails. I've only tested with 4 and -1.

Steps to reproduce:
1. Create scoreboard "name"
2. Add target player "x" with negative score eg. -1 and selector player "y" with a positive score eg. 4
3. /scoreboard players operation "x" "name" %= "y" "name"

Result:
Command succeeds, but x is not changed. In my case where target is -1 and selectors is 4, target should become 3.

Comments 2

I believe this is how java works. Upon testing with a small program, running -1 % 4 returns -1. I expect in java modulus is not defined for negative numbers.

It's intended. https://en.wikipedia.org/wiki/Modulo_operation Modulo finds a remainder, ether always positive or positive/negative (depends on the code). So, in java (- 1)%4=- (1%4)=-1

Silas

(Unassigned)

Unconfirmed

Minecraft 1.9.1 Pre-Release 3

Retrieved