floatobject.h 1.5 KB

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