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: Sébastien Hinderer <Sebastien.Hinderer@e...>
Subject: Re: [Caml-list] 32-bit unsigned integers
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