idiv - luxembourg/muxcode-clm GitHub Wiki

IDIV()

FUNCTION: idiv(<number1>,<number2>)

Returns the integer quotient from dividing <number1> by <number2>.

However, integer division for the case where either <integer1> or <integer2> is negative is defined in a specific way -- by choosing the smallest integer that is greater than or equal to the algebraic quotient. If <integer1> and <integer2> are the same sign, then idiv() and floordiv() are equivalent.

For example, division of -9 by 5 would give -1 by this definition instead of -2. idiv() would return -1. floordiv() would return -2.

idiv(x,y)*y + remainder(x,y) ==> x

Examples: > say idiv(15,3) You say, "5" > say idiv(16,3) You say, "5" > say idiv(17,3) You say, "5" > say idiv(18,3) You say, "6" > say idiv(-17,3) You say, "-5"

Related Topics: iadd, imul, isub, fdiv, floordiv, fmod, mod, remainder().