() mod ()

From PenguinMod Wiki (Official)
Jump to navigation Jump to search

The () mod () is an operator reporter block from Scratch which reports the remainder of dividing the first and second inputs. The mod part is short for "modulo". Both inputs are empty by default.

Behavior with negative numbers

When the first number is negative while the other one is positive, this block will return a positive remainder. For example, -10 mod 3 = 2 because -10 + 3 * 4 = 2. When the second number is negative, this block will return a negative remainder. For example, 10 mod -3 = -2 because 10 - 3 * 4 = -2, and -10 mod -3 = -1 because -10 + 3 * 3 = -1. This is consistent with the actual modulo operator.