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:

    Then I had only prisoners’ thoughts. I awaited the daily walk which I took in the yard, or my lawyer’s visit. I managed the remainder of my time very well. I have often thought that if I was made to live in a dry tree trunk, without any other occupation but to watch the flower of the sky above my head, I would have gradually gotten used to it.
    Albert Camus (1913–1960)

    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)

    No doubt, to a man of sense, travel offers advantages. As many languages as he has, as many friends, as many arts and trades, so many times is he a man. A foreign country is a point of comparison, wherefrom to judge his own.
    Ralph Waldo Emerson (1803–1882)