to_str


Description:

[ CCode ( cname = "g_ascii_dtostr" , instance_pos = -1 ) ]
public unowned string to_str (char[] buffer)

Converts a `gdouble` to a string, using the '.

' as decimal point.

This function generates enough precision that converting the string back using [func@GLib.ascii_strtod] gives the same machine-number (on machines with IEEE compatible 64bit doubles). It is guaranteed that the size of the resulting string will never be larger than [ const@GLib.ASCII_DTOSTR_BUF_SIZE] bytes, including the terminating nul character, which is always added.

Example: Double to string (with buffer):

public static int main (string[] args) {
// Output: ``20``
char[] buf = new char[double.DTOSTR_BUF_SIZE];
unowned string str = (20.0).to_str (buf);
print ("%s\n", str);
return 0;
}

valac --pkg glib-2.0 double.to_str.vala

Parameters:

buffer

a buffer to place the resulting string in

buf_len

the length of the buffer

d

the value to convert

Returns:

the pointer to the buffer with the converted string