English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: localization, internationalization and Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-10-25 (18:54)
From: skaller <skaller@m...>
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