Terminology for the Division Algorithm [00DE]

In this definition, q is called the quotient and r the remainder. We write \begin {align*} q &= a \mathbin {\mathbf {div}} d \\ r &= a \mathbin {\mathbf {mod}} d \end {align*} The \mathbin {\mathbf {div}} operator is written / in Java and C/C++, and // in Python and Disco; the \mathbin {\mathbf {mod}} operator is written % in many programming languages, and mod in Disco.

Note, however, that the \mathbin {\mathbf {div}} and \mathbin {\mathbf {mod}} operators in Java, C/C++, and Rust do not work in the same way as specified above. In particular, in those languages, the result of a \mathbin {\mathbf {mod}} d is negative when a is negative, rather than always returning a result in the range 0 \leq r < d. Languages such as Python, Disco, and Haskell implement \mathbin {\mathbf {mod}} correctly.