From: edgar <edgarrft@we...>  20100624 20:34:20

paul beach wrote: > Rem seems to be more general than mod. Should be useful for multiple > congruences,(the socalled Chinese remainder theory). Also there is a > (gcd a b), meaning greatest common divisor. Even though there is no MOD > statement, LISP seems to be superior with respect to NUMBER theory. Some > topics would be, primitive roots, quadratic residues, congruence. > > Just checking that (rem a b) is the same as modulus: > > Nyquist prompt: > > (rem 22 5) ; == 22 mod 5 > > Output =2 > > Much better than this, > > ( 22 (* 5 (/ 22 5))) ; no error checking! I am not a really good mathematician to tell the truth, but here is what the Common Lisp Standard says about the difference between REM and MOD: http://www.lispworks.com/documentation/HyperSpec/Body/f_mod_r.htm#rem In one sentence: REM and MOD differ in their handling of positive and negative numbers. If both number have the same sign, both functions behave the same: (rem 1 5) => 1 (mod 1 5) => 1 (rem 1 5) => 1 (mod 1 5) => 1 But if both numbers have unequal signs: (rem 1 5) => 1 (mod 1 5) => 4 (rem 1 5) => 1 (mod 1 5) => 4 I'm afraid if this is important to you than there will be no other way than to write a realmath solution. I will try now to write a Lisp version out of these examples: http://en.wikipedia.org/wiki/Modulo_operation But do not expect too much...  edgar  The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: 