Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 ?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: