Commit 008adc74 authored by Stefan Behnel's avatar Stefan Behnel

Handle integer comparison in the gap between the maximum multiple PyLong...

Handle integer comparison in the gap between the maximum multiple PyLong digits that fit into a long completely and LONG_MAX.
parent 3317ad4a
......@@ -760,9 +760,17 @@ static CYTHON_INLINE {{c_ret_type}} __Pyx_PyInt_{{'' if ret_type.is_pyobject els
if ((0));
{{for _size in range(4, 1, -1)}}
#if PyLong_SHIFT * {{_size}} < SIZEOF_LONG*8
else if (uintval >= {{_size-1}}UL * (unsigned long) PyLong_BASE)
else if (uintval >= {{_size-1}}UL * (unsigned long) PyLong_BASE) {
if (uintval >= {{_size}}UL * (unsigned long) PyLong_BASE) {
// int value is between the maximum multiple digits that fit into a long completely and the maximum long value
unequal = (size != {{_size+1}}) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
{{for _i in range(1, _size+1)}} | (digits[{{_i}}] != ((uintval >> ({{_i}} * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)){{endfor}};
} else {
// int value is within the maximum multiple digits that fit into a long completely
unequal = (size != {{_size}}) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
{{for _i in range(1, _size)}} | (digits[{{_i}}] != ((uintval >> ({{_i}} * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)){{endfor}};
}
}
#endif
{{endfor}}
else unequal = (size != 1) || (digits[0] != (uintval & (unsigned long) PyLong_MASK));
......
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