1
2 /* Float object interface */
3
4 /*
5 PyFloatObject represents a (double precision) floating point number.
6 */
7
8 #ifndef Py_FLOATOBJECT_H
9 #define Py_FLOATOBJECT_H
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 PyAPI_DATA(PyTypeObject) PyFloat_Type;
15
16 #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
17 #define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
18
19 #define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
20
21 #define Py_RETURN_INF(sign) \
22 do { \
23 if (copysign(1., sign) == 1.) { \
24 return PyFloat_FromDouble(Py_HUGE_VAL); \
25 } \
26 else { \
27 return PyFloat_FromDouble(-Py_HUGE_VAL); \
28 } \
29 } while(0)
30
31 PyAPI_FUNC(double) PyFloat_GetMax(void);
32 PyAPI_FUNC(double) PyFloat_GetMin(void);
33 PyAPI_FUNC(PyObject*) PyFloat_GetInfo(void);
34
35 /* Return Python float from string PyObject. */
36 PyAPI_FUNC(PyObject*) PyFloat_FromString(PyObject*);
37
38 /* Return Python float from C double. */
39 PyAPI_FUNC(PyObject*) PyFloat_FromDouble(double);
40
41 /* Extract C double from Python float. The macro version trades safety for
42 speed. */
43 PyAPI_FUNC(double) PyFloat_AsDouble(PyObject*);
44
45 #ifndef Py_LIMITED_API
46 # define Py_CPYTHON_FLOATOBJECT_H
47 # include "cpython/floatobject.h"
48 # undef Py_CPYTHON_FLOATOBJECT_H
49 #endif
50
51 #ifdef __cplusplus
52 }
53 #endif
54 #endif /* !Py_FLOATOBJECT_H */