How to format a float?

From: skaller (skaller@maxtal.com.au)
Date: Mon Oct 25 1999 - 02:54:38 MET DST


Date: Mon, 25 Oct 1999 10:54:38 +1000
From: skaller <skaller@maxtal.com.au>
To: caml-list@inria.fr
Subject: How to format a float?

How do I format a floating point number
correctly in ocaml, with a given _variable_
width and precision?

I can't find a routine in the library for this.
Shouldn't there be one? Did I miss it?

--
sprintf is not suitable, the format string
must be a literal. string_of_float has
no arguments, and it gives the wrong format
if the number happens to be integral.
I need to write a 'printf' like routine.

It's relatively easy to write an integer formatting routine, but floats are somewhat more difficult.

-- John Skaller, mailto:skaller@maxtal.com.au 1/10 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller downloads: http://www.triode.net.au/~skaller



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:27 MET