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 HAA27760; Sun, 5 Aug 2001 07:26:34 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA27545 for ; Sun, 5 Aug 2001 07:26:33 +0200 (MET DST) Received: from mail.mimuw.edu.pl (pm93.warszawa.cvx.ppp.tpnet.pl [213.76.108.93]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f755QTb11723 for ; Sun, 5 Aug 2001 07:26:30 +0200 (MET DST) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id WAA04497 for caml-list@inria.fr; Sat, 4 Aug 2001 22:25:38 +0200 X-Authentication-Warning: qrnik.zagroda: news set sender to Marcin 'Qrczak' Kowalczyk using -f From: "Marcin 'Qrczak' Kowalczyk" Subject: Re: [Caml-list] Integer arithmetic: mod Date: 4 Aug 2001 20:25:35 GMT Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <9khicj$3n3$1@qrnik.zagroda> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: qrnik.zagroda 996956735 4482 192.168.0.1 (4 Aug 2001 20:25:35 GMT) X-Complaints-To: news@qrnik.zagroda NNTP-Posting-Date: 4 Aug 2001 20:25:35 GMT X-Licznik: 24260 User-Agent: slrn/0.9.7.0 (pl-1.1.0) (Linux/2.2.17 (i686)) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Sat, 04 Aug 2001 11:48:07 -0700, Chris Hecker pisze: > Most computer languages (and chips) simply say "(a/b)*b + a mod b = > a" and leave it at that. Fortunately not all, e.g. in Python (-123) % 10 == 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 = -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 = -2". Haskell has both: div & mod truncate downwards, quot & rem truncate towards 0. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA 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