From f3de9fb1675ef92942197992f54e8a751734b34d Mon Sep 17 00:00:00 2001
From: Athan Reines <kgryte@gmail.com>
Date: Wed, 15 Nov 2023 13:28:45 -0800
Subject: [PATCH 1/3] feat: add specification for determining whether a sign
 bit is set

---
 .../elementwise_functions.rst                 |  1 +
 .../_draft/elementwise_functions.py           | 33 +++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/spec/draft/API_specification/elementwise_functions.rst b/spec/draft/API_specification/elementwise_functions.rst
index 8048eb38a..b3f08727b 100644
--- a/spec/draft/API_specification/elementwise_functions.rst
+++ b/spec/draft/API_specification/elementwise_functions.rst
@@ -69,6 +69,7 @@ Objects in API
    remainder
    round
    sign
+   signbit
    sin
    sinh
    square
diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py
index faaa9213b..d49710301 100644
--- a/src/array_api_stubs/_draft/elementwise_functions.py
+++ b/src/array_api_stubs/_draft/elementwise_functions.py
@@ -51,6 +51,7 @@
     "remainder",
     "round",
     "sign",
+    "signbit",
     "sin",
     "sinh",
     "square",
@@ -2215,6 +2216,38 @@ def sign(x: array, /) -> array:
     """
 
 
+def signbit(x: array, /) -> array:
+    r"""
+    Determines whether the sign bit is set for each element ``x_i`` of the input array ``x``.
+
+    Parameters
+    ----------
+    x: array
+        input array. Should have a real-valued floating-point data type.
+
+    Returns
+    -------
+    out: array
+        an array containing the evaluated result for each element in ``x``. The returned array must have a data type of ``bool``.
+
+    Notes
+    -----
+
+    **Special cases**
+
+    For real-valued floating-point operands,
+
+    - If ``x_i`` is ``+0``, the result is ``False``.
+    - If ``x_i`` is ``-0``, the result is ``True``.
+    - If ``x_i`` is ``+infinity``, the result is ``False``.
+    - If ``x_i`` is ``-infinity``, the result is ``True``.
+    - If ``x_i`` is a positive (i.e., greater than ``0``) finite number, the result is ``False``.
+    - If ``x_i`` is a negative (i.e., less than ``0``) finite number, the result is ``True``.
+    - If ``x_i`` is ``NaN`` and the sign bit of ``x_i`` is ``0``, the result is ``False``.
+    - If ``x_i`` is ``NaN`` and the sign bit of ``x_i`` is ``1``, the result is ``True``.
+    """
+
+
 def sin(x: array, /) -> array:
     r"""
     Calculates an implementation-dependent approximation to the sine for each element ``x_i`` of the input array ``x``.

From 3b594940be132f9668855e6916717408945aee74 Mon Sep 17 00:00:00 2001
From: Athan Reines <kgryte@gmail.com>
Date: Thu, 30 Nov 2023 02:37:27 -0800
Subject: [PATCH 2/3] Add extended description describing when a sign bit is
 set

---
 src/array_api_stubs/_draft/elementwise_functions.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py
index d49710301..936a8f584 100644
--- a/src/array_api_stubs/_draft/elementwise_functions.py
+++ b/src/array_api_stubs/_draft/elementwise_functions.py
@@ -2220,6 +2220,8 @@ def signbit(x: array, /) -> array:
     r"""
     Determines whether the sign bit is set for each element ``x_i`` of the input array ``x``.
 
+    The sign bit of a real-valued floating-point number ``x_i`` is set whenever ``x_i`` is either ``-0``, less than zero, or a signed ``NaN`` (i.e., a ``NaN`` value whose sign bit is set).
+
     Parameters
     ----------
     x: array

From 6579c5e487c2553c025ae8ef33b5c41631ec7ed7 Mon Sep 17 00:00:00 2001
From: Athan Reines <kgryte@gmail.com>
Date: Thu, 30 Nov 2023 02:41:23 -0800
Subject: [PATCH 3/3] Update description to avoid circular reasoning

---
 src/array_api_stubs/_draft/elementwise_functions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py
index 936a8f584..57cb6f455 100644
--- a/src/array_api_stubs/_draft/elementwise_functions.py
+++ b/src/array_api_stubs/_draft/elementwise_functions.py
@@ -2220,7 +2220,7 @@ def signbit(x: array, /) -> array:
     r"""
     Determines whether the sign bit is set for each element ``x_i`` of the input array ``x``.
 
-    The sign bit of a real-valued floating-point number ``x_i`` is set whenever ``x_i`` is either ``-0``, less than zero, or a signed ``NaN`` (i.e., a ``NaN`` value whose sign bit is set).
+    The sign bit of a real-valued floating-point number ``x_i`` is set whenever ``x_i`` is either ``-0``, less than zero, or a signed ``NaN`` (i.e., a ``NaN`` value whose sign bit is ``1``).
 
     Parameters
     ----------