How exactly is the remainder procedure related to the
quotient procedure?
They complement each other, giving you the two pieces of information that
result from the division of one integer by another: quotient
tells you how many times the divisor goes into the dividend, and
remainder tells you how many units of the dividend are left
over.
Is remainder subject to the same restrictions as
quotient, then?
Yes: It must receive exactly two operands, both operands must be integers, and the second operand (the divisor) must not be zero.
What is the sign of the value that remainder returns if one or
both of the operands is negative?
If the division comes out even, of course, the remainder is zero. Otherwise, the sign of the result is the same as the sign of the dividend:
This makes sense, if you think about it: The units that are ``left over'' after the division are units within the dividend, so they have the same sign as the dividend.> (remainder -45 6) -3 > (remainder 45 -6) 3 > (remainder -45 -6) -3
Next topic
Previous topic
Table of contents
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/scheme-web/remainder.html