Skip to content

idivide

general · scripts/general/idivide.m

: C = idivide (A, B)
: C = idivide (A, B, op)

Integer division with a selectable rounding rule.

At least one of A and B must be of an integer class; if both are, the classes must agree. The other operand may be a floating point array. The quotient A ./ B is rounded according to op and the result, of the integer class, saturates at the class limits. op is one of

"fix" (default)

round toward zero

"zero"

synonym for "fix"

"floor"

round toward minus infinity

"ceil"

round toward plus infinity

"round"

round to nearest, halves away from zero

Quotients of integers are computed exactly, also for 64-bit classes. Division by zero saturates (positive to the maximum, negative to the minimum, 0/0 gives 0).