math_floor(PyObject *module, PyObject *number)
/*[clinic end generated code: output=c6a65c4884884b8a input=63af6b5d7ebcc3d6]*/
{
+ double x;
+
_Py_IDENTIFIER(__floor__);
- if (!PyFloat_CheckExact(number)) {
+ if (PyFloat_CheckExact(number)) {
+ x = PyFloat_AS_DOUBLE(number);
+ }
+ else
+ {
PyObject *method = _PyObject_LookupSpecial(number, &PyId___floor__);
if (method != NULL) {
PyObject *result = _PyObject_CallNoArg(method);
}
if (PyErr_Occurred())
return NULL;
+ x = PyFloat_AsDouble(number);
+ if (x == -1.0 && PyErr_Occurred())
+ return NULL;
}
- double x = PyFloat_AsDouble(number);
- if (x == -1.0 && PyErr_Occurred())
- return NULL;
-
return PyLong_FromDouble(floor(x));
}