Commit ebf10c7f authored by scoder's avatar scoder

Merge pull request #493 from Nikratio/master

FROM_PY_FUNCTION: Cast to sdigit after unary minus, not before
parents eca0803d 9c100bce
...@@ -659,7 +659,8 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO ...@@ -659,7 +659,8 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
x = a % b; x = a % b;
x += ((x != 0) & ((x ^ b) < 0)) * b; x += ((x != 0) & ((x ^ b) < 0)) * b;
{{elif op == 'TrueDivide'}} {{elif op == 'TrueDivide'}}
if (8 * sizeof(long) <= 53 || (__Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) || likely(labs({{ival}}) <= (1L << 53))) { if ((8 * sizeof(long) <= 53 || likely(labs({{ival}}) <= (1L << 53)))
|| __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
return PyFloat_FromDouble((double)a / (double)b); return PyFloat_FromDouble((double)a / (double)b);
} }
return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2); return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2);
......
...@@ -685,7 +685,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { ...@@ -685,7 +685,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
const digit* digits = ((PyLongObject*)x)->ob_digit; const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) { switch (Py_SIZE(x)) {
case 0: return ({{TYPE}}) 0; case 0: return ({{TYPE}}) 0;
case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, -(sdigit) digits[0]) case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, (sdigit) -digits[0])
case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, +digits[0]) case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, +digits[0])
{{for _size in (2, 3, 4)}} {{for _size in (2, 3, 4)}}
{{for _case in (-_size, _size)}} {{for _case in (-_size, _size)}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment