Re: [gnome-db] Gda_Value_Stringify of a double

On Mon, 2006-10-23 at 09:51 -0300, Juan Pablo wrote:
> Hello list.
> When i use this function with a gda value double, it generates a 2
> decimal number, rounding it up. For example, 0.895 double becomes "0.90"
> string.
> I would like to have 4 decimas. Is this a parameter?

I can't see what possible use this function has:

 * gda_value_stringify
 * @value: a #GValue.
 * Converts a GValue to its string representation which is a human
readable value. Note that the
 * returned string does not take into account the current locale of the
user (on the contrary to the
 * #GdaDataHandler objects).
 * Dates are converted in a YYYY-MM-DD format.
 * Returns: a new string, or %NULL if the conversion cannot be done.
Free the value with a g_free() when you've finished
 * using it. 

It says that string is meant to be human-readable, but it ignores the
current locale, and it makes assumptions about the numeric formatting
wanted. So it's no use for actually showing to a human. I suggest that
it be marked as "useful only for debugging, and not for showing values
in your user interface."

> Meanwhile, i made a function wich does the same BUT it uses a static
> buffer for the return and the format is parametrizable. No need to use
> intermediate variables which needs to be freed. 
> Is there any reason to not to do so with gda_value_stringify? (the
> static char part) If the string is needed on a new var you just strdup
> it.

Murray Cumming
murrayc murrayc com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]