# % (Modulo) ## Category Arithmetic ## Arity **Binary** — left operand % right operand. ``` % ``` ## Description Returns the remainder after dividing the left operand by the right operand. Auto-unwraps `shared` values before operating. **Modulo by zero throws `SqTypeError`.** ## How It Works Performs `double` floating-point modulo via `a % b = a - b * floor(a / b)`. This matches C# `%` behavior for doubles, not truncated integer remainder. The host checks for zero divisor. ## Usage ### Basic modulo ```sqf _result = 10 % 3; // 1 _remainder = 17 % 5; // 2 _isEven = (_num % 2) == 0; ``` ### Wrap-around / cycling ```sqf _index = (_index + 1) % _arrayCount; // wrap index _angle = _angle % 360; // normalize angle ``` ### Periodic checks ```sqf // Run every 5th frame if (_frame % 5 == 0) then { doPeriodicWork(); }; ``` ## Errors - **`SqTypeError`** — thrown when divisor is `0`. ## Thread Safety Not atomic. Regular modulo on primitives is thread-safe. ## See Also - [/](div.md) — division - [floor](floor.md) — floor rounding - [round](round.md) — nearest integer