Skip to content

rem

Remainder of division (truncated, sign of dividend).

C = rem(A, B)

Returns A - fix(A/B) * B. The result has the same sign as A (rem(-5, 3) = -2, not 1). Use mod for the always-positive form.

rem(7, 3) % 1
rem(-7, 3) % -1 (sign of dividend)
  • mod — Modulo operation (positive result).
  • quotient — Integer portion of a division.