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 TAA16087; Mon, 26 Jul 2004 19:49:28 +0200 (MET DST) 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 TAA14950 for ; Mon, 26 Jul 2004 19:49:27 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6QHnPEV030965 for ; Mon, 26 Jul 2004 19:49:26 +0200 Received: by mproxy.gmail.com with SMTP id m69so84467rne for ; Mon, 26 Jul 2004 10:49:25 -0700 (PDT) Received: by 10.38.11.77 with SMTP id 77mr18891rnk; Mon, 26 Jul 2004 10:49:25 -0700 (PDT) Message-ID: Date: Mon, 26 Jul 2004 10:49:25 -0700 From: "Corey O'Connor" To: caml-list@inria.fr Subject: Re: [Caml-list] 32-bit unsigned integers In-Reply-To: <20040726171517.GA19032@galois> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <20040726171517.GA19032@galois> X-Miltered: at nez-perce with ID 41054426.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; corey:99 caml-list:01 font:99 val:01 2004:99 ens-lyon:01 modulus:01 constants:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 -bit:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ah! I asked the same question just a bit ago! A "language extension" to Ocaml (Make sure you have 3.07.11 or greater) is to directly assign 32 bit integers without using Int32.of_string. Just add an "l" to the end of the constant. (Lower case "L" if your font is strange and it looks like a 1 | I) It's like so: # let blah =3D 0x8FFFFFFFl;; val blah : int32 =3D -1879048193l # -Corey=20 On Mon, 26 Jul 2004 19:15:18 +0200, S=E9bastien Hinderer wrote: > Hi again, >=20 > > Yes: it's called int32. Think about it: being "unsigned" or "signed" > > is not a property of the representation (it will be 32 binary digits > > in both cases), it's just that some operations (division, modulus and > > comparisons) interpret those bits differently. >=20 > Sorry, I was caught by the fact they are signed. >=20 > However, I'm not sure it is so easy. Indeed, the representation and the r= ange > of represented integers has to be exactly the same than with the uint32_t > type of C, to allow me to use some constants defined in C in Caml program= s. >=20 > Consider for instance the following definition in a .h C header file : >=20 > #define UINT32_MAX (4294967295U) >=20 > Now I'd like to define the same thing in Caml: >=20 > # let uint32_max =3D Int32.of_string "4294967295";; > Exception: Failure "int_of_string". >=20 > How can I solve this problem ? >=20 > Thanks, > S=E9bastien. >=20 >=20 >=20 > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inr= ia.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 >=20 --=20 -Corey O'Connor ------------------- 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