Floating Point Objects

PyFloatObject

This subtype ofPyObject represents a Python floating point object.

PyTypeObjectPyFloat_Type

This instance ofPyTypeObject represents the Python floating pointtype. This is the same object asfloat in the Python layer.

intPyFloat_Check(PyObject *p)

Return true if its argument is aPyFloatObject or a subtype ofPyFloatObject. This function always succeeds.

intPyFloat_CheckExact(PyObject *p)

Return true if its argument is aPyFloatObject, but not a subtype ofPyFloatObject. This function always succeeds.

PyObject*PyFloat_FromString(PyObject *str)
Return value: New reference.

Create aPyFloatObject object based on the string value instr, orNULL on failure.

PyObject*PyFloat_FromDouble(double v)
Return value: New reference.

Create aPyFloatObject object fromv, orNULL on failure.

doublePyFloat_AsDouble(PyObject *pyfloat)

Return a Cdouble representation of the contents ofpyfloat. Ifpyfloat is not a Python floating point object but has a__float__()method, this method will first be called to convertpyfloat into a float.If__float__() is not defined then it falls back to__index__().This method returns-1.0 upon failure, so one should callPyErr_Occurred() to check for errors.

Changed in version 3.8:Use__index__() if available.

doublePyFloat_AS_DOUBLE(PyObject *pyfloat)

Return a Cdouble representation of the contents ofpyfloat, butwithout error checking.

PyObject*PyFloat_GetInfo(void)
Return value: New reference.

Return a structseq instance which contains information about theprecision, minimum and maximum values of a float. It’s a thin wrapperaround the header filefloat.h.

doublePyFloat_GetMax()

Return the maximum representable finite floatDBL_MAX as Cdouble.

doublePyFloat_GetMin()

Return the minimum normalized positive floatDBL_MIN as Cdouble.