Subject: Re: remainder
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1998/01/18
Newsgroups: comp.lang.scheme
Message-ID: <69rsv1$1d96l@fido.asd.sgi.com>

Keith Wright <kwright@kwright.tiac.net> wrote:
+---------------
| Klaus M. Rodewig writes:
| > Can anyone tell me what "remainder" exactly does?
| 
| For integers n, d, and r,
| (remainder n d) ==> r,
|  where r is the least positive integer such that n = kd + r for some k.
+---------------

Close, but not quite. For "remainder", a non-zero "r" must have the
same sign as "n". Whereas for "modulo", "r" has the same sign as "d".
See R4RS section 6.5.5 (p.22):

    (modulo -13 4)    ==>  3
    (remainder -13 4) ==> -1

    (modulo 13 -4)    ==> -3
    (remainder 13 -4) ==>  1


-Rob

-----
Rob Warnock, 7L-551		rpw3@sgi.com   http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673 [New area code!]
2011 N. Shoreline Blvd.		FAX: 650-933-4392
Mountain View, CA  94043	PP-ASEL-IA