Remainder - Quotient and Remainder in Programming Languages

Quotient and Remainder in Programming Languages

With two choices for the inequality, there are two choices for the remainder, one negative and the other positive. This means that there are also two possible choices for the quotient. In number theory the positive remainder is chosen by convention. But programming languages need not, and different languages have adopted different conventions: C99 and Pascal choose the remainder with the same sign as the dividend a. (Before C99, the C language allowed either choice.) Perl, Python (only modern versions), and Common Lisp choose the remainder with the same sign as the divisor d. Haskell and Scheme offer two functions, remainder and modulo – Fortran has mod and modulo; the former agrees in sign with the dividend, and the latter with the divisor.

Read more about this topic:  Remainder

Famous quotes containing the words remainder, programming and/or languages:

    “What have I gained?”
    “Experience,” said Holmes, laughing. “Indirectly it may be of value, you know; you have only to put it into words to gain the reputation of being excellent company for the remainder of your existence.”
    Sir Arthur Conan Doyle (1859–1930)

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)

    I am always sorry when any language is lost, because languages are the pedigree of nations.
    Samuel Johnson (1709–1784)