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
[Caml-list] string_of_float -> float_of_string locale dependency bug
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-14 (16:25)
From: Shawn Wagner <shawnw@s...>
Subject: Re: [Caml-list] string_of_float -> float_of_string locale dependency bug
On Mon, Jun 14, 2004 at 06:04:20PM +0200, Xavier Leroy wrote:
> > Another approach: write own strtod function which doesn't depend on
> > the LC_NUMERIC locale.
> Of course, having our own string <-> float conversions would work
> around this issue and other issues as well, such as the inability of
> the C library functions to print a float *exactly* (i.e. with just
> enough decimals that it reads back to the very same float).
> This is no small undertaking, however, and one has a feeling of
> reinventing the wheel.
> The ANSI C standard library is quite small to begin with, but the
> addition of locales managed to render it even less useful...

While I agree that LC_NUMERIC makes converting floats into strings that are
intended to be converted back into floats by other programs a major pain,
locales aren't all bad. Adding locale support and ctype.h routines was one
of the first things I did for annexlib. Being able to do things like case
conversion according to the user's character set is very nice.

*braces for people griping about how that's fundamentally broken too*

Shawn Wagner

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: