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 OAA14415; Wed, 22 Jan 2003 14:51:49 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA14157 for ; Wed, 22 Jan 2003 14:51:48 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from mel-rto2.wanadoo.fr (smtp-out-2.wanadoo.fr [193.252.19.254]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h0MDpmv00793 for ; Wed, 22 Jan 2003 14:51:48 +0100 (MET) Received: from mel-rta6.wanadoo.fr (193.252.19.26) by mel-rto2.wanadoo.fr (6.7.015) id 3E0C337000FD4393; Wed, 22 Jan 2003 14:51:48 +0100 Received: from warp (80.11.88.179) by mel-rta6.wanadoo.fr (6.7.015) id 3E26CE21003A8F5E; Wed, 22 Jan 2003 14:51:48 +0100 Message-ID: <013b01c2c21d$f0b8d3c0$b3580b50@warp> From: "Nicolas Cannasse" To: , "Christoph Bauer" References: Subject: Re: [Caml-list] Need unsigned int Date: Wed, 22 Jan 2003 14:55:36 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > my program need to calculate a hash key of a matrix (with dimension 8 > x 8). It is necessary that this calculation is very fast, so my > program will update the hash key after every small modification of the > matrix. My problem is that the hash key should be an unsigned int > or an unsigned long in. > > My problem occurs here (Mersenne prime number 2^31-1): > let big_prim = 2147483647 > val big_prim : int = -1 OCaml does not of unsigned integers. Using Int64 or Bignum modules as Sven suggested you would be a threat to your program performances since it involves boxing. BTW, why do care about the integer sign ? Only the printer show you -1, but the hardware representation, taking note that OCaml int are 31 bits, doesn't change between signed and unsigned, does it ? The only main difference I see is when comparing two signed integers. Then perhaps something like : let ui_compare x y = x lsr 16 < y lsr 16 || x land 0xFFFF < y land 0xFFFF Is what you need. ui_compare 1 2;; // true ui_compare (-1) 2;; // false Nicolas Cannasse ------------------- 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