浮點數(Floating Point)物件¶
-
PyTypeObject
PyFloat_Type¶ This instance of
PyTypeObjectrepresents the Python floating point type. This is the same object asfloatin the Python layer.
-
int
PyFloat_Check(PyObject *p)¶ Return true if its argument is a
PyFloatObjector a subtype ofPyFloatObject.
-
int
PyFloat_CheckExact(PyObject *p)¶ Return true if its argument is a
PyFloatObject, but not a subtype ofPyFloatObject.
-
PyObject*
PyFloat_FromString(PyObject *str)¶ - Return value: New reference.
Create a
PyFloatObjectobject based on the string value in str, or NULL on failure.
-
PyObject*
PyFloat_FromDouble(double v)¶ - Return value: New reference.
Create a
PyFloatObjectobject from v, or NULL on failure.
-
double
PyFloat_AsDouble(PyObject *pyfloat)¶ 返回一个 C
double代表 pyfloat 的内容。 如果 pyfloat 不是一个 Python 浮点数对象但是具有__float__()方法,此方法将首先被调用,将 pyfloat 转换成一个数点数。 如果__float__()未定义则将回退至__index__()。 如果失败,此方法将返回-1.0,因此开发者应当调用PyErr_Occurred()来检查错误。3.8 版更變: 如果可用将使用
__index__()。
-
double
PyFloat_AS_DOUBLE(PyObject *pyfloat)¶ Return a C
doublerepresentation of the contents of pyfloat, but without error checking.
-
PyObject*
PyFloat_GetInfo(void)¶ - Return value: New reference.
Return a structseq instance which contains information about the precision, minimum and maximum values of a float. It's a thin wrapper around the header file
float.h.
-
double
PyFloat_GetMax()¶ Return the maximum representable finite float DBL_MAX as C
double.
-
double
PyFloat_GetMin()¶ Return the minimum normalized positive float DBL_MIN as C
double.
-
int
PyFloat_ClearFreeList()¶ Clear the float free list. Return the number of items that could not be freed.
