On Tue, Sep 04, 2007 at 11:55:58PM +0200, Magnus Myrefors wrote: > > I tried with strtod() but it only worked with strings with no > decimal-point, otherwise the resulting double was truncated. > ... > > - if the numbers are normal, i.e. supported by underlying > > strtod(), try to use it directly -- be careful with the ^^^^^^^^^^^^^^^^^^^ > > locale in this case ^^^^^^^^^^^^^^^^^^^
strtod() is locale dependent, g_ascii_strtod() is not (well, sort of, it uses strtod() so if the locale or strtod() implementation is weird, g_ascii_strtod() can be still affected). This is what g_ascii_strtod() is all about. Your locale uses decimal comma or something like that. As if I didn't warn... > I also tried to copy g_ascii_strtod() (from glib-2.12-9) into > my code but it didn't compile My crystal ball says you are missing #include <locale.h> but it's a bit cloudy. > and I didn't quite understand > the if-statement if(decimal_point_pos) {} where decimal_point_pos > was declared as const char *decimal_point_pos. > I thought that a pointer was an address in memory and I haven't > seen a pointer in a if-statement like that before. That's a common idiom. NULL is zero and zero is false. Anything else is nonzero and therefore true. > I guess I have to write my own conversion-function. Good luck with that (I still think a bug in the program and not in GLib is the most probable cause). Yeti -- http://gwyddion.net/ _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list