# Idiv()

## Description

FUNCTION: **idiv**(*number1*, *number2*)

Returns the integer quotient from dividing *number1* by *number*.

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

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

## 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"

## Server Differences

On TinyMUX, the built-in function **idiv()** is aliased to div(), but on PennMUSH and TinyMUSH, the built-in function is div(). TinyMUX support 64-bit integers on both 32-bit and 64-bit platforms. PennMUSH and TinyMUSH support the platform's native integer size (either 32-bit or 64-bit).

Use div() to obtain the same behavior across all three servers.