From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA22503 for caml-redistribution; Mon, 25 Oct 1999 20:54:36 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA04849 for ; Mon, 25 Oct 1999 00:28:04 +0200 (MET DST) Received: from ruby (pm1-8.triode.net.au [203.63.235.24]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id AAA20353 for ; Mon, 25 Oct 1999 00:27:59 +0200 (MET DST) Received: from maxtal.com.au (IDENT:root@localhost [127.0.0.1]) by ruby (8.9.3/8.9.3) with ESMTP id KAA01548 for ; Mon, 25 Oct 1999 10:54:38 +1000 Sender: weis Message-ID: <3813AA4E.7016C100@maxtal.com.au> Date: Mon, 25 Oct 1999 10:54:38 +1000 From: skaller Organization: Maxtal X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: How to format a float? References: <380CB30E.56D1A8A2@maxtal.com.au> <99102100543400.15513@ice> <380F0157.CDBBAD7D@k-bell.com> <380F32A4.8E5ECC5F@maxtal.com.au> <380F3EE2.B86682E4@k-bell.com> <380F4105.E1DDD31E@maxtal.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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