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 BAA32430; Fri, 24 Jan 2003 01:39:59 +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 BAA32520 for ; Fri, 24 Jan 2003 01:39:58 +0100 (MET) Received: from TheWorld.com (pcls3.std.com [199.172.62.105]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0O0dsr22036 for ; Fri, 24 Jan 2003 01:39:56 +0100 (MET) Received: from watergate.world.std.com (pool-141-149-175-233.bos.east.verizon.net [141.149.175.233]) by TheWorld.com (8.9.3/8.9.3) with ESMTP id TAA09654 for ; Thu, 23 Jan 2003 19:39:48 -0500 Message-Id: <5.2.0.9.0.20030123193356.06829da8@pop.theWorld.com> X-Sender: chase@pop.theWorld.com X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 Date: Thu, 23 Jan 2003 19:39:47 -0500 To: From: David Chase Subject: Re: [Caml-list] Need unsigned int In-Reply-To: <74C51A70-2EE3-11D7-9F00-0003930FCE12@inria.fr> References: <013b01c2c21d$f0b8d3c0$b3580b50@warp> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk My CAML skills are poor, especially on bitwise operations, but here is how one does (or can do) unsigned in Java: public static boolean lessThan(int x, int y) { return ((x^y) >= 0) ? (x < y) : (y < x); }; That is, if the signs are the same, then signed and unsigned compares agree. Otherwise, the negative one is larger. Another way to phrase this might be (if you hate control flow): return ((x^y) >>> 31) ^ (x < y); The reasoning here is that if the signs agree, then 0 XOR any == any. Otherwise, if the signs disagree, then x and y are surely not equal, so (y