From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA11573; Mon, 6 Aug 2001 15:27:43 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA11629 for ; Mon, 6 Aug 2001 15:27:42 +0200 (MET DST) Received: from mrwall.kal.com (mrwall.kal.com [194.193.14.236]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f76DRfD10692 for ; Mon, 6 Aug 2001 15:27:41 +0200 (MET DST) Received: from mrwall.kal.com [194.193.14.236] (HELO localhost) by mrwall.kal.com (AltaVista Mail V2.0J/2.0J BL25J listener) id 0000_002b_3b6e_9beb_7aed; Mon, 06 Aug 2001 14:30:19 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-2" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Integer arithmetic: mod content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 Date: Mon, 6 Aug 2001 14:23:24 +0100 Message-ID: <8E31D6933A2FE64F8AE3CC1381EEDCE70B3418@NT.kal.com> Thread-Topic: [Caml-list] Integer arithmetic: mod Thread-Index: AcEdbx4cCB6S7N2ERTe2Ehagh1/CEwBDEDhQ From: "Dave Berry" To: Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk The Standard ML Basis Library also has both div/mod and rem/quot. (This was after some people complained that the original language definition required the slower, Knuth-approved, behaviour). -----Original Message----- From: Marcin 'Qrczak' Kowalczyk [mailto:qrczak@knm.org.pl] Sent: 04 August 2001 21:26 To: caml-list@inria.fr Subject: Re: [Caml-list] Integer arithmetic: mod Sat, 04 Aug 2001 11:48:07 -0700, Chris Hecker pisze: > Most computer languages (and chips) simply say "(a/b)*b + a mod b =3D > a" and leave it at that. Fortunately not all, e.g. in Python (-123) % 10 =3D=3D 7. In C89 the behavior for negative numbers was left implementation-defined but in C99 it is specified as truncation towards 0. > Unfortunately, people (and language and chip designers) assume > (-4)/3 =3D -1 (truncate towards zero) rather than -2 (floor), Not all people: Donald Knuth clearly disagrees. He has written something along the lines "beware of programming languages which use a different definition than the one which says (-4)/3 =3D -2". Haskell has both: div & mod truncate downwards, quot & rem truncate towards 0. --=20 __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST=CAPCZA QRCZAK ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr