Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] sprintf-Bug?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: Re: [Caml-list] sprintf-Bug?
> > 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
( 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

> Thanks,
>    Oliver