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
[Caml-list] Bug? Printf, %X and negative numbers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-04-01 (08:20)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers
> Having looked at it a bit myself, the fix will probable be *ahem* 
> interesting.  Effectively, you have to stop using C's printf.  Either 
> that, or parse the format string a second (third?) time to see wether you 
> need to do a signed or unsigned int conversion.

It's no big deal, really.  (See the working sources on
The formats are already parsed three(!) times:
  - once in Caml (module Printf)
  - once in C to determine the size of the buffer to hold the result
        (file byterun/ints.c)
  - once in the printf() C library function itself.
The way I fixed it, the signed/unsigned distinction is done in the
second parsing, although it could also be done during the first.

> Or, I suppose, we could 
> completely redesign Ocaml to use 32-bit ints and do something else to 
> differentiate ints from pointers :-).

If you can find a "something else" that is faster than systematically
boxing the 32-bit ints, you'll be hailed as the savior in compiler
circles :-)

- Xavier Leroy

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