Skip to content

idivide

Integer division with controllable rounding.

C = idivide(A, B)
C = idivide(A, B, mode)

Returns the integer division of A by B elementwise. The optional mode controls how non-integer quotients are rounded:

  • 'fix' (default) — truncate toward zero
  • 'round' — round to nearest, ties to even
  • 'floor' — round toward negative infinity
  • 'ceil' — round toward positive infinity

A and B must be integer types (or convertible to one).

idivide(int32(7), int32(2)) % 3
idivide(int32(-7), int32(2)) % -3 (truncation)
idivide(int32(-7), int32(2), 'floor') % -4
  • mrdivide — Matrix right division (A / B).
  • mldivide — Matrix left division (A \ B).