From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 77AC9BC0B for ; Sun, 4 Feb 2007 11:04:18 +0100 (CET) Received: from orion.metastack.com (no-dns-yet.demon.co.uk [80.177.38.218] (may be forged)) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l14A4HGZ018023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 4 Feb 2007 11:04:18 +0100 Received: from treble (cpc2-cmbg6-0-0-cust535.cmbg.cable.ntl.com [81.107.34.24]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id l149KApH011287 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Sun, 4 Feb 2007 09:20:10 GMT From: "David Allsopp" To: References: <20070204020819.B999DBC6F@yquem.inria.fr> Subject: Re: [Caml-list] sprintf-Bug? Date: Sun, 4 Feb 2007 10:04:17 -0000 Organization: MetaStack Solutions Ltd. Message-ID: <022101c74843$d57064b0$6a7ba8c0@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AcdH+00liEHpmg4wQE6fQsTnJnnBNgARvuog In-Reply-To: <20070204020819.B999DBC6F@yquem.inria.fr> X-Miltered: at discorde with ID 45C5AFA1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 sprintf:01 printf:01 sprintf:01 printf:01 o'caml:01 flags:01 libref:01 opengroup:01 onlinepubs:01 wrote:01 oliver:01 oliver:01 behaviour:01 caml-list:01 > > Oliver Bandel wrote: > But why didn't worked the code with the two sprintf's?! > The outer sprintf should have do what I was looking for?! Printf.sprintf "%0X" converts a number to a capitalised hex *string* (the 0 is pointless without a width specification --- there will never be padding) Printf.sprintf "%02s" inserts a *string* ensuring that it is at least two characters long. The '0' is ignored --- the O'Caml manual states that the '0' and '+' flags are for numerical conversion only (http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html). I guess you could argue that "%02s" is not a valid format and so should raise This is also the behaviour of ISO C sprintf (http://www.opengroup.org/onlinepubs/009695399/functions/printf.html) > Thanks, > Oliver David