Re: Posix(?) on numeric entry



antongiulio wrote:
[...]
gdouble value = 4.1;
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];

gtk_entry_set_text (GTK_ENTRY (value_entry), \
      g_ascii_dtostr(buffer, G_ASCII_DTOSTR_BUF_SIZE, value));
but on output I got for value -> 4.0999999999999996

How can I "round" value? Or g_ascii_formatd(...) is more appropriate?
Yes, try smth like: g_formatd(buffer, sizeof(buffer), "%.1g", value).

	Olexiy




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