summaryrefslogtreecommitdiff
path: root/Include/floatobject.h
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-04-18 23:13:07 +0000
committerChristian Heimes <christian@cheimes.de>2008-04-18 23:13:07 +0000
commit6f34109384f3a78d5f4f8bdd418a89caca19631e (patch)
treef5b446eb4cd2993b6be5a373148530976ce39f4b /Include/floatobject.h
parent858a77099e094ce4ef57778d38230ec36db2e805 (diff)
downloadcpython-git-6f34109384f3a78d5f4f8bdd418a89caca19631e.tar.gz
I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
The patch also adds acosh, asinh, atanh, log1p and copysign to all platforms. Finally it fixes differences between platforms like different results or exceptions for edge cases. Have fun :)
Diffstat (limited to 'Include/floatobject.h')
-rw-r--r--Include/floatobject.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 0e5f6a9472..91814f2a6e 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -21,6 +21,17 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
+#ifdef Py_NAN
+#define Py_RETURN_NAN PyFloat_FromDouble(Py_NAN)
+#endif
+
+#define Py_RETURN_INF(sign) do \
+ if (copysign(1., sign) == 1.) { \
+ return PyFloat_FromDouble(Py_HUGE_VAL); \
+ } else { \
+ return PyFloat_FromDouble(-Py_HUGE_VAL); \
+ } while(0)
+
PyAPI_FUNC(double) PyFloat_GetMax(void);
PyAPI_FUNC(double) PyFloat_GetMin(void);
PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);