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 HAA18862; Fri, 7 Nov 2003 07:22:33 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 HAA18918 for ; Fri, 7 Nov 2003 07:22:32 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from eposta.kablonet.com.tr ([62.248.102.66]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id hA76MU102491 for ; Fri, 7 Nov 2003 07:22:31 +0100 (MET) Received: (qmail 53029 invoked by uid 0); 7 Nov 2003 06:27:38 -0000 Received: from unknown (HELO 195.174.173.82) (exa@kablonet.com.tr@195.174.173.82) by 0 with SMTP; 7 Nov 2003 06:27:38 -0000 From: Eray Ozkural Reply-To: erayo@cs.bilkent.edu.tr Organization: Bilkent University CS Dept. To: Jacques Garrigue Subject: Re: [Caml-list] A grave bug in logical shift right op? Date: Fri, 7 Nov 2003 08:22:21 +0200 User-Agent: KMail/1.5.93 Cc: caml-list@inria.fr References: <200311070535.00172.exa@kablonet.com.tr> <20031107125304T.garrigue@kurims.kyoto-u.ac.jp> In-Reply-To: <20031107125304T.garrigue@kurims.kyoto-u.ac.jp> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200311070822.22104.exa@kablonet.com.tr> X-Loop: caml-list@inria.fr X-Spam: no; 0.00; eray:01 ozkural:01 caml-list:01 grave:01 bug:01 conditioned:99 jacques:01 litteral:01 fffffff:01 floats:01 jacques:01 eray:01 ozkural:01 erayo:01 bilkent:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Excuse me for forgetting this fact about the ocaml int type. Having been too accustomed to C/C++, I must have conditioned myself into thinking int couldn't possibly be 31 bits. I swear I had learnt it sometime in the past only to forget it :) Thanks for the clarification. On Friday 07 November 2003 05:53, Jacques Garrigue wrote: > Sure, the int type has only 31 bits. In good math, > (2 ^ 31 - 1) quo 2 ^ 24 is 127, as far as I know. > > Note that the problem with your first example has already been > discussed. A litteral bigger than the biggest possible integer should > probably trigger an error/exception. > A bit more curions is your second example: since > 0xffffffff = 0x7fffffff = -1, converting it to int32 gives -1l (the > 32-bit value for -1), which happens to be 0xffffffffl. > > If you want to do 32-bit computations, you must use only 32-bit > integers. This shouldn't be too inefficient as long as you use loops > rather than function calls (the same recommandations as for floats > apply, I believe). > > Jacques Garrigue -- Eray Ozkural (exa) Comp. Sci. Dept., Bilkent University, Ankara KDE Project: http://www.kde.org www: http://www.cs.bilkent.edu.tr/~erayo Malfunction: http://mp3.com/ariza GPG public key fingerprint: 360C 852F 88B0 A745 F31B EA0F 7C07 AE16 874D 539C ------------------- 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/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners