Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers
> $ ocaml
>         Objective Caml version 3.06
> 
> # Printf.printf "%08X\n" (1 lsl 30);;
> C0000000
> 
> I expected output of 40000000, not C0000000.  Note that this isn't a case 
> of simple sign extension, as the second example demonstrates.  Where'd the 
> extra bit come from?

As Yutaka Oiwa said, it comes from the conversion from Caml 31-bit
integers to C 32-bit integers, which performs sign extension.

Even though 0x40000000 and 0xC0000000 denote the same Caml int, I
agree this behavior is very surprising and should be fixed.  I'll look
into this.  Thanks for reporting the issue.

- Xavier Leroy

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