On Mon, 5 Feb 2007, Christian Lerrahn wrote:
> Am Sun, 4 Feb 2007 22:02:15 -0800 (PST)
> schrieb Martin Jambon < martin_jambon%40emailuser.net">martin_jambon
emailuser.net>:
>
> > On Mon, 5 Feb 2007, Christian Lerrahn wrote:
> >
> > > Hi,
> > > is it possible to specify a format for floats in string_of_float.
> > > E.g. could I say that I want 5 decimals or e.g. an xxe+/-yy
> > > notation like 1.56e23? I know that I can do that with fprintf or
> > > sprintf but is it also possible in string_of_float?
> >
> > No. What's wrong with sprintf?
>
> I thought sprintf was not type safe whereas string_of_float was but I
> found out that sprintf seems to be type safe as well. So I really don't
> need string_of_float.
The only dangerous thing with the printf functions is that partial
applications used to not work as expected, but it's not the case anymore.
If I recall correctly, before you would get:
# let f = Printf.printf "Hello %s";;
Helloval f : string -> unit = <fun>
# f "x";;
x- : unit = ()
... which was always surprising.
But in ocaml 3.09.3 (I don't know since when exactly but this is
documented somewhere) you get:
# let f = Printf.printf "Hello %s";;
val f : string -> unit = <fun>
# f "x";;
Hello x- : unit = ()
That's nicer.
Martin
--
Martin Jambon
http://martin.jambon.free.fr
.