Differenze tra le versioni di "Convertire un numero di tipo stringa in un valore di tipo Float con la funzione PyOS string to double() della libreria libpython3.4m"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "La libreria ''libpython3.4m'' è un interfaccia in C di funzioni appartenenti alle risorse di ''Python''. La funzione ''PyOS_string_to_double( )'' consente di convertire un...") |
|||
Riga 17: | Riga 17: | ||
Dim f As Float | Dim f As Float | ||
− | + | ||
− | |||
f = PyOS_string_to_double("123.456789", 0, 0) | f = PyOS_string_to_double("123.456789", 0, 0) | ||
Versione delle 02:49, 23 ago 2016
La libreria libpython3.4m è un interfaccia in C di funzioni appartenenti alle risorse di Python.
La funzione PyOS_string_to_double( ) consente di convertire un valore numererico di tipo stringa in un valore di tipo Float.
Per poter fruire in Gambas di tale funzione esterna, è necessario richiamare la libreria dinamica condivisa: "libpython3.4m.so.1.0"
Mostriamo un semplice esempio pratico:
Library "libpython3.4m:1.0" ' (double) PyOS_string_to_double(const char *str, char **endptr, PyObject *overflow_exception) ' Convert a string s to a double. Private Extern PyOS_string_to_double(strs As String, endptr As Pointer, overflow_exception As Pointer) As Float Public Sub Main() Dim f As Float f = PyOS_string_to_double("123.456789", 0, 0) Print f End