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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 07F65BC0A for ; Sun, 4 Feb 2007 02:55:34 +0100 (CET) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.229]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l141tWgm018494 for ; Sun, 4 Feb 2007 02:55:33 +0100 Received: by nz-out-0506.google.com with SMTP id l8so1296317nzf for ; Sat, 03 Feb 2007 17:55:32 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=E+NzA/PUPM7ABWkSmxJimJ667ZTgzrvSwFLgiiwb+rmkgBggP5Nr1TSNFMtWQktOv7cIvpjJaLFj8/BC1indduMJf8QsbQvmZJ5wQSGt4rFTF6aWviB1YxptNzTZsNVBrLnz192AO1hA4iH6TnP3lPJYgYG64rRYGMMRl/TM3LQ= Received: by 10.114.175.16 with SMTP id x16mr491180wae.1170554132029; Sat, 03 Feb 2007 17:55:32 -0800 (PST) Received: by 10.115.107.15 with HTTP; Sat, 3 Feb 2007 17:55:32 -0800 (PST) Message-ID: Date: Sun, 4 Feb 2007 14:55:32 +1300 From: "Jonathan Roewen" To: "Oliver Bandel" Subject: Re: [Caml-list] sprintf-Bug? Cc: caml-list@inria.fr In-Reply-To: <20070204015122.GA3882@first.in-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070204010040.GC3829@first.in-berlin.de> <20070204015122.GA3882@first.in-berlin.de> X-j-chkmail-Score: MSGID : 45C53D14.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45C53D14.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; c-style:01 printf:01 bandel:01 in-berlin:01 byte:01 printf:01 sprintf:01 sprintf:01 beginner's:01 ocaml:01 bug:01 beginners:01 wrote:01 wrote:01 imho:01 I gave the example :P "%02X" prints a number as hex, 2 chars in length (assuming no more than 2 chars wide), padded with zeroes. Same as you'd do in any other lang with C-style printf. On 2/4/07, Oliver Bandel wrote: > On Sun, Feb 04, 2007 at 02:11:43PM +1300, Jonathan Roewen wrote: > > Don't think so. I'm pretty sure padding of strings is only with > > spaces. > > The format-string "%02s" should make a '0' instead of ' ' > as filling, IMHO. > > > > Padding of numbers has to be specified for a number format. > > IMHO "%2s" should make a string of at least two chars > length, fillingup with ' ' on the left side. > > And "%0s" should make it with a filling-char '0' > instead of filling-chars ' '. > > > > > > > let hex_of_byte b = Printf.sprintf "%02X" b;; > > > > Why you'd use two sprintfs is the real oddity =P > > The inner sprintf makes hex from int and the outer > makes two-char-string instead of one-char-string. > > Or how to make hex-output with filling '0' instead > of ' ' for two-char length strings? > > Would a "%00X" work?! > > > Ciao, > Oliver > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >