Georg Brandl | 54a3faa | 2008-01-20 09:30:57 +0000 | [diff] [blame] | 1 | .. highlightlang:: c |
| 2 | |
| 3 | .. _floatobjects: |
| 4 | |
| 5 | Floating Point Objects |
| 6 | ---------------------- |
| 7 | |
| 8 | .. index:: object: floating point |
| 9 | |
| 10 | |
| 11 | .. ctype:: PyFloatObject |
| 12 | |
| 13 | This subtype of :ctype:`PyObject` represents a Python floating point object. |
| 14 | |
| 15 | |
| 16 | .. cvar:: PyTypeObject PyFloat_Type |
| 17 | |
| 18 | .. index:: single: FloatType (in modules types) |
| 19 | |
| 20 | This instance of :ctype:`PyTypeObject` represents the Python floating point |
| 21 | type. This is the same object as ``float`` and ``types.FloatType``. |
| 22 | |
| 23 | |
| 24 | .. cfunction:: int PyFloat_Check(PyObject *p) |
| 25 | |
| 26 | Return true if its argument is a :ctype:`PyFloatObject` or a subtype of |
| 27 | :ctype:`PyFloatObject`. |
| 28 | |
| 29 | |
| 30 | .. cfunction:: int PyFloat_CheckExact(PyObject *p) |
| 31 | |
| 32 | Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of |
| 33 | :ctype:`PyFloatObject`. |
| 34 | |
| 35 | |
| 36 | .. cfunction:: PyObject* PyFloat_FromString(PyObject *str) |
| 37 | |
| 38 | Create a :ctype:`PyFloatObject` object based on the string value in *str*, or |
| 39 | *NULL* on failure. |
| 40 | |
| 41 | |
| 42 | .. cfunction:: PyObject* PyFloat_FromDouble(double v) |
| 43 | |
| 44 | Create a :ctype:`PyFloatObject` object from *v*, or *NULL* on failure. |
| 45 | |
| 46 | |
| 47 | .. cfunction:: double PyFloat_AsDouble(PyObject *pyfloat) |
| 48 | |
| 49 | Return a C :ctype:`double` representation of the contents of *pyfloat*. If |
| 50 | *pyfloat* is not a Python floating point object but has a :meth:`__float__` |
| 51 | method, this method will first be called to convert *pyfloat* into a float. |
| 52 | |
| 53 | |
| 54 | .. cfunction:: double PyFloat_AS_DOUBLE(PyObject *pyfloat) |
| 55 | |
| 56 | Return a C :ctype:`double` representation of the contents of *pyfloat*, but |
| 57 | without error checking. |
| 58 | |
| 59 | |
| 60 | .. cfunction:: PyObject* PyFloat_GetInfo(void) |
| 61 | |
| 62 | Return a structseq instance which contains information about the |
| 63 | precision, minimum and maximum values of a float. It's a thin wrapper |
| 64 | around the header file :file:`float.h`. |
| 65 | |
| 66 | |
| 67 | .. cfunction:: double PyFloat_GetMax(void) |
| 68 | |
| 69 | Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`. |
| 70 | |
| 71 | |
| 72 | .. cfunction:: double PyFloat_GetMin(void) |
| 73 | |
| 74 | Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. |
Christian Heimes | 15ebc88 | 2008-02-04 18:48:49 +0000 | [diff] [blame] | 75 | |
Georg Brandl | 2ee470f | 2008-07-16 12:55:28 +0000 | [diff] [blame] | 76 | .. cfunction:: int PyFloat_ClearFreeList(void) |
Christian Heimes | 15ebc88 | 2008-02-04 18:48:49 +0000 | [diff] [blame] | 77 | |
Georg Brandl | 2ee470f | 2008-07-16 12:55:28 +0000 | [diff] [blame] | 78 | Clear the float free list. Return the number of items that could not |
| 79 | be freed. |