@@ -73,6 +73,43 @@ The following functions provide locale-independent string to number conversions.
73
73
The return value is a pointer to *buffer * with the converted string or NULL if
74
74
the conversion failed.
75
75
76
+ .. deprecated :: 3.1
77
+ Use :cfunc: `PyOS_double_to_string ` instead.
78
+
79
+
80
+ .. cfunction :: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
81
+
82
+ Convert a :ctype: `double ` *val * to a string using supplied
83
+ *format_code *, *precision *, and *flags *.
84
+
85
+ *format_code * must be one of ``'e' ``, ``'E' ``, ``'f' ``, ``'F' ``, ``'g' ``,
86
+ ``'G' ``, ``'s' ``, or ``'r' ``. For ``'s' `` and ``'r' ``, the supplied
87
+ *precision * must be 0 and is ignored. These specify the standard
88
+ :func: `str ` and :func: `repr ` formats, respectively.
89
+
90
+ *flags * can be zero or more of the values *Py_DTSF_SIGN *,
91
+ *Py_DTSF_ADD_DOT_0 *, or *Py_DTSF_ALT *, or-ed together:
92
+
93
+ * *Py_DTSF_SIGN * means to always precede the returned string with a sign
94
+ character, even if *val * is non-negative.
95
+
96
+ * *Py_DTSF_ADD_DOT_0 * means to ensure that the returned string will not look
97
+ like an integer.
98
+
99
+ * *Py_DTSF_ALT * means to apply "alternate" formatting rules. See the
100
+ documentation for the :cfunc: `PyOS_snprintf ` ``'#' `` specifier for
101
+ details.
102
+
103
+ If *ptype * is non-NULL, then the value it points to will be set to one of
104
+ *Py_DTST_FINITE *, *Py_DTST_INFINITE *, or *Py_DTST_NAN *, signifying that
105
+ *val * is a finite number, an infinite number, or not a number, respectively.
106
+
107
+ The return value is a pointer to *buffer * with the converted string or
108
+ *NULL * if the conversion failed. The caller is responsible for freeing the
109
+ returned string by calling :cfunc: `PyMem_Free `.
110
+
111
+ .. versionadded :: 3.1
112
+
76
113
77
114
.. cfunction :: double PyOS_ascii_atof(const char *nptr)
78
115
0 commit comments