From: Michael Ulm Date: 2006-08-11T23:17:46+09:00 Subject: Re: Confused by Bignum#remainder Chris Gehlker wrote: > > On Aug 11, 2006, at 2:16 AM, Michael Ulm wrote: > >> Chris Gehlker wrote: >> >> --snip-- >> >>> A couple of years ago I took a discrete math course and was very >>> surprised to find division defined as: >>> "Let a be an integer and d a *positive* integer. Then there are >>> unique integers q and r, with 0 .le. r .le d, such that a = dq + >>> r. Apparently my elementary school teacher had lied to me by saying >>> that division was even defined for a non-positive divisor. >>> Furthermore, an examination of the above definition will show that >>> my calculator has always lied to me for negative dividends since >>> the remainder must by definition be non-negative. >> >> --snip-- >> >> You do not understand the difference between a theorem and a definition. > > > Actually, i do. I was just trying to state the so called "division > algorithm". > >> The statement you quote is a theorem. It does not define division but >> states a property of the integers. This property as stated holds if the >> assumptions of the theorem (d is a positive integer) hold. This theorem >> then can be used to define the modulo function. > > > I think you may be missing the point. The theorem can be used to define > *a* modulo function but not one which will serve to answer the original > question which was about the case where the assumption that d is > positive does not hold. My, rather trivial, point was that language > implementors do what feels right to them in this case and who can blame > them? > > The more interesting case is when the dividend is negative. Here Ruby > does the 'right thing' but many languages do not. > OK. I understand now. What I took to be an attack on mathematics as it was taught to you was just an ellipse to get to the main point. Sorry for the misunderstanding. And I do agree with your main point, except that I _do_ blame the language implementors and designers. As you pointed out, Ruby does it right. If other languages do it wrong I do hold it against them. Best regards, Michael -- Michael Ulm R&D Team ISIS Information Systems Austria tel: +43 2236 27551-219, fax: +43 2236 21081 e-mail: michael.ulm@isis-papyrus.com Visit our Website: www.isis-papyrus.com --------------------------------------------------------------- This e-mail is only intended for the recipient and not legally binding. Unauthorised use, publication, reproduction or disclosure of the content of this e-mail is not permitted. This email has been checked for known viruses, but ISIS accepts no responsibility for malicious or inappropriate content. ---------------------------------------------------------------