From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 49E17BC0B for ; Fri, 8 Dec 2006 19:37:23 +0100 (CET) Received: from WelcometoMail (www.janestcapital.com [66.155.124.107]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kB8IbLoA020227 for ; Fri, 8 Dec 2006 19:37:22 +0100 Received: from [192.168.250.117] [209.213.205.130] by janestcapital.com with ESMTP (SMTPD-9.10) id A0E00214; Fri, 08 Dec 2006 13:37:20 -0500 Message-ID: <4579B0E0.9050304@janestcapital.com> Date: Fri, 08 Dec 2006 13:37:20 -0500 From: Brian Hurt User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Mattias_Engdeg=E5rd?= Cc: jon@ffconsultancy.com, caml-list@yquem.inria.fr Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE References: <45785E27.8050804@naughtydog.com> <200612071943.kB7JhC522308@virtutech.se> <200612081748.03288.jon@ffconsultancy.com> <200612081820.kB8IKL023123@virtutech.se> In-Reply-To: <200612081820.kB8IKL023123@virtutech.se> Content-Type: multipart/alternative; boundary="------------070700020408070901050303" X-j-chkmail-Score: MSGID : 4579B0E1.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 4579B0E1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mattias:01 bug:01 integers:01 semantics:01 mattias:01 bug:01 integers:01 semantics:01 stone:98 stone:98 wrote:01 wrote:01 caml-list:01 arithmetic:01 arithmetic:01 This is a multi-part message in MIME format. --------------070700020408070901050303 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Mattias Engdegård wrote: >>I wouldn't call it a bug. It looks like modulo arithmetic to me. >> >> > >Let's not make a virtue of necessity. The type "int" was likely designed >with the intent to provide a type that could be used for actual integers >in a variety of circumstances, while giving good performance. The modulo >semantics is rarely useful (especially the 30-bit signed variety) but >is the price paid for reasonable performance with a simple implementation. > > Actually, the modulo behavior comes out of how the CPU designers made the CPUs work decades ago. It was very easy for them to just drop all those extra bits (or not even compute them). And, of course, now that behavior is cast in stone... Brian --------------070700020408070901050303 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Mattias Engdegård wrote:
I wouldn't call it a bug. It looks like modulo arithmetic to me.
    

Let's not make a virtue of necessity. The type "int" was likely designed
with the intent to provide a type that could be used for actual integers
in a variety of circumstances, while giving good performance. The modulo
semantics is rarely useful (especially the 30-bit signed variety) but
is the price paid for reasonable performance with a simple implementation.
  
Actually, the modulo behavior comes out of how the CPU designers made the CPUs work decades ago.  It was very easy for them to just drop all those extra bits (or not even compute them).  And, of course, now that behavior is cast in stone...

Brian

--------------070700020408070901050303--