Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] 32-bit unsigned integers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Corey O'Connor <coreyoconnor@g...>
Subject: Re: [Caml-list] 32-bit unsigned integers
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 = 0x8FFFFFFFl;;
val blah : int32 = -1879048193l
#

-Corey 

On Mon, 26 Jul 2004 19:15:18 +0200, Sébastien Hinderer
<sebastien.hinderer@ens-lyon.org> wrote:
> Hi again,
> 
> > 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.
> 
> Sorry, I was caught by the fact they are signed.
> 
> However, I'm not sure it is so easy. Indeed, the representation and the range
> 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 programs.
> 
> Consider for instance the following definition in a .h C header file :
> 
> #define UINT32_MAX (4294967295U)
> 
> Now I'd like to define the same thing in Caml:
> 
> # let uint32_max = Int32.of_string "4294967295";;
> Exception: Failure "int_of_string".
> 
> How can I solve this problem ?
> 
> Thanks,
> Sébastien.
> 
> 
> 
> -------------------
> 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
> 


-- 
-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