caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] sprintf-Bug?
Date: Sun, 4 Feb 2007 10:04:17 -0000	[thread overview]
Message-ID: <022101c74843$d57064b0$6a7ba8c0@treble> (raw)
In-Reply-To: <20070204020819.B999DBC6F@yquem.inria.fr>

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


       reply	other threads:[~2007-02-04 10:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070204020819.B999DBC6F@yquem.inria.fr>
2007-02-04 10:04 ` David Allsopp [this message]
2007-02-04  1:00 sprintf-Bug? Oliver Bandel
2007-02-04  1:11 ` [Caml-list] sprintf-Bug? Jonathan Roewen
2007-02-04  1:51   ` Oliver Bandel
2007-02-04  1:55     ` Jonathan Roewen
     [not found]     ` <45C53E45.1080109@rftp.com>
2007-02-04  2:08       ` Oliver Bandel
2007-02-04  2:11         ` Jonathan Roewen
2007-02-04 12:43           ` Oliver Bandel
2007-02-04 10:41     ` Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='022101c74843$d57064b0$6a7ba8c0@treble' \
    --to=dra-news@metastack.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).