From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22472; Sun, 30 Mar 2003 11:51:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA22544 for ; Sun, 30 Mar 2003 11:51:22 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2U9pB501792; Sun, 30 Mar 2003 11:51:12 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22466; Sun, 30 Mar 2003 11:51:11 +0200 (MET DST) Date: Sun, 30 Mar 2003 11:51:11 +0200 From: Xavier Leroy To: Brian Hurt Cc: Ocaml Mailing List Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers Message-ID: <20030330115111.A22539@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from brian.hurt@qlogic.com on Fri, Mar 28, 2003 at 03:19:16PM -0600 X-Spam: no; 0.00; caml-list:01 bug:01 printf:01 3.06:01 yutaka:01 oiwa:01 -bit:01 ocaml:01 caml:01 surprising:01 int:01 behavior:03 integers:05 output:05 objective:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > $ 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