]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141004: Document `Py_RETURN_NAN` and `Py_RETURN_INF` (GH-141029)
authorPeter Bierma <zintensitydev@gmail.com>
Wed, 5 Nov 2025 22:00:26 +0000 (17:00 -0500)
committerGitHub <noreply@github.com>
Wed, 5 Nov 2025 22:00:26 +0000 (17:00 -0500)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Doc/c-api/float.rst

index 489676caa3a16a8e10deebe774b5e81b832657a6..1085c32a53707122b5c5250310bf357265f2c213 100644 (file)
@@ -78,6 +78,23 @@ Floating-Point Objects
    Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.
 
 
+.. c:macro:: Py_RETURN_NAN
+
+   Return :data:`math.nan` from a function.
+
+   On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``.
+
+
+.. c:macro:: Py_RETURN_INF(sign)
+
+   Return :data:`math.inf` or :data:`-math.inf <math.inf>` from a function,
+   depending on the sign of *sign*.
+
+   On most platforms, this is equivalent to the following::
+
+      return PyFloat_FromDouble(copysign(INFINITY, sign));
+
+
 Pack and Unpack functions
 -------------------------