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 DAA03876; Mon, 6 Aug 2001 03:07:29 +0200 (MET DST) 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 DAA03896 for ; Mon, 6 Aug 2001 03:07:28 +0200 (MET DST) Received: from bastion.artisan.com (bastion.artisan.com [209.144.161.130]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f7617QH26059 for ; Mon, 6 Aug 2001 03:07:27 +0200 (MET DST) Received: from ypmaster.artisan.com (ypmaster [172.16.2.1]) by bastion.artisan.com (8.9.2/8.9.2) with ESMTP id SAA14975 for ; Sun, 5 Aug 2001 18:07:00 -0700 (PDT) Received: from ish.artisan.com (ish [172.16.10.79]) by ypmaster.artisan.com (8.9.2/8.9.2) with ESMTP id SAA19945 for ; Sun, 5 Aug 2001 18:06:57 -0700 (PDT) Received: (from johnm@localhost) by ish.artisan.com (8.9.2/8.9.2) id SAA08423; Sun, 5 Aug 2001 18:06:57 -0700 (PDT) X-Authentication-Warning: ish.artisan.com: johnm set sender to johnm@artisan.com using -f From: John Gerard Malecki MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15213.60847.742324.692106@ish.artisan.com> Date: Sun, 5 Aug 2001 18:06:55 -0700 To: caml-list@inria.fr Subject: Re: [Caml-list] Integer arithmetic: mod In-Reply-To: References: X-Mailer: VM 6.92 under Emacs 20.4.1 X-Organization: Artisan Components, Inc. Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Does anyone know if the hardware implementation of integer division and/or remainder is faster because the returned value from remainder is sometimes negative? Maybe its slower but everyone does it the same way for backwards compatibility? One reason for the hardware remainder to be positive is that it allows for easier compiler optimizations. If the remainder is always positive then the following transformations are always available: M / (2**N) == M asr N M mod (2**N) == M land (2**N-1) I guess it doesn't much matter as this optimization is normally applied to array indices which usually are non-negative anyway. PS - i'm not sure if this trick also works with 1s complement representation but when was the last time anyone built one of those machines? ------------------- 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