mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-135853: add math.signbit
(#135877)
This commit is contained in:
parent
ff7b5d44a0
commit
42ccac2d7f
6 changed files with 81 additions and 3 deletions
|
@ -1233,6 +1233,23 @@ FUNC2(remainder, m_remainder,
|
|||
"Return x - n*y where n*y is the closest integer multiple of y.\n"
|
||||
"In the case where x is exactly halfway between two multiples of\n"
|
||||
"y, the nearest even value of n is used. The result is always exact.")
|
||||
|
||||
/*[clinic input]
|
||||
math.signbit
|
||||
|
||||
x: double
|
||||
/
|
||||
|
||||
Return True if the sign of x is negative and False otherwise.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
math_signbit_impl(PyObject *module, double x)
|
||||
/*[clinic end generated code: output=20c5f20156a9b871 input=3d3493fbcb5bdb3e]*/
|
||||
{
|
||||
return PyBool_FromLong(signbit(x));
|
||||
}
|
||||
|
||||
FUNC1D(sin, sin, 0,
|
||||
"sin($module, x, /)\n--\n\n"
|
||||
"Return the sine of x (measured in radians).",
|
||||
|
@ -4199,6 +4216,7 @@ static PyMethodDef math_methods[] = {
|
|||
MATH_POW_METHODDEF
|
||||
MATH_RADIANS_METHODDEF
|
||||
{"remainder", _PyCFunction_CAST(math_remainder), METH_FASTCALL, math_remainder_doc},
|
||||
MATH_SIGNBIT_METHODDEF
|
||||
{"sin", math_sin, METH_O, math_sin_doc},
|
||||
{"sinh", math_sinh, METH_O, math_sinh_doc},
|
||||
{"sqrt", math_sqrt, METH_O, math_sqrt_doc},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue