CKTIS / Python
Operator %=
Replaces the stored number with its remainder after floor division by the right operand.
Version: Python 3.14; repository image, production runtime not attested
Syntax
target %= valueReplaces the stored number with its remainder after floor division by the right operand.
Use this update to reduce an integer cursor to the range of a positive period. The target is evaluated only once, including when it is an indexed slot.
For built-in integers the magnitude of the result is strictly less than that of the nonzero divisor and any nonzero remainder has its sign. Floating-point rounding can produce a remainder as large in magnitude as the divisor.
For a negative integer divisor the stored remainder is negative or zero.
Syntax
target %= value
__imod__, __mod__, __rmod__ · ZeroDivisionError
Worked example
n = 7; n %= -3
n → -2
-1e-100 % 1e100 == 1e100 → True
Examples
value = 19
value %= -4
print(value)
print(type(value).__name__)
Result
-1 int
For a negative integer divisor the stored remainder is negative or zero.