浮點數(Floating Point)物件¶
-
PyTypeObject
PyFloat_Type
¶ This instance of
PyTypeObject
represents the Python floating point type. This is the same object asfloat
in the Python layer.
-
int
PyFloat_Check
(PyObject *p)¶ Return true if its argument is a
PyFloatObject
or 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.
根据字符串 str 的值创建一个
PyFloatObject
,失败时返回NULL
。
-
PyObject*
PyFloat_FromDouble
(double v)¶ - Return value: New reference.
根据 v 创建一个
PyFloatObject
对象,失败时返回NULL
。
-
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
double
representation 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.