A few more minor fixes in longobject.c
This commit is contained in:
parent
2ffb26fb83
commit
bcf6b18eb7
|
@ -19,6 +19,7 @@ extern "C" {
|
||||||
long_pow() requires that SHIFT be divisible by 5. */
|
long_pow() requires that SHIFT be divisible by 5. */
|
||||||
|
|
||||||
typedef unsigned short digit;
|
typedef unsigned short digit;
|
||||||
|
typedef short sdigit; /* signed variant of digit */
|
||||||
#define BASE_TWODIGITS_TYPE long
|
#define BASE_TWODIGITS_TYPE long
|
||||||
typedef unsigned BASE_TWODIGITS_TYPE twodigits;
|
typedef unsigned BASE_TWODIGITS_TYPE twodigits;
|
||||||
typedef BASE_TWODIGITS_TYPE stwodigits; /* signed variant of twodigits */
|
typedef BASE_TWODIGITS_TYPE stwodigits; /* signed variant of twodigits */
|
||||||
|
|
|
@ -63,7 +63,7 @@ long_normalize(register PyLongObject *v)
|
||||||
PyLongObject *
|
PyLongObject *
|
||||||
_PyLong_New(Py_ssize_t size)
|
_PyLong_New(Py_ssize_t size)
|
||||||
{
|
{
|
||||||
if (size > MAX_LONG_DIGITS) {
|
if (size > (Py_ssize_t)MAX_LONG_DIGITS) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"too many digits in integer");
|
"too many digits in integer");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1945,7 +1945,7 @@ long_compare(PyLongObject *a, PyLongObject *b)
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
sign = 0;
|
sign = 0;
|
||||||
else {
|
else {
|
||||||
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
|
sign = (sdigit)a->ob_digit[i] - (sdigit)b->ob_digit[i];
|
||||||
if (Py_SIZE(a) < 0)
|
if (Py_SIZE(a) < 0)
|
||||||
sign = -sign;
|
sign = -sign;
|
||||||
}
|
}
|
||||||
|
@ -2865,7 +2865,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
for (i = Py_SIZE(b) - 1; i >= 0; --i) {
|
for (i = Py_SIZE(b) - 1; i >= 0; --i) {
|
||||||
digit bi = b->ob_digit[i];
|
digit bi = b->ob_digit[i];
|
||||||
|
|
||||||
for (j = 1 << (PyLong_SHIFT-1); j != 0; j >>= 1) {
|
for (j = (digit)1 << (PyLong_SHIFT-1); j != 0; j >>= 1) {
|
||||||
MULT(z, z, z)
|
MULT(z, z, z)
|
||||||
if (bi & j)
|
if (bi & j)
|
||||||
MULT(z, a, z)
|
MULT(z, a, z)
|
||||||
|
@ -3099,9 +3099,8 @@ long_bitwise(PyLongObject *a,
|
||||||
{
|
{
|
||||||
digit maska, maskb; /* 0 or PyLong_MASK */
|
digit maska, maskb; /* 0 or PyLong_MASK */
|
||||||
int negz;
|
int negz;
|
||||||
Py_ssize_t size_a, size_b, size_z;
|
Py_ssize_t size_a, size_b, size_z, i;
|
||||||
PyLongObject *z;
|
PyLongObject *z;
|
||||||
int i;
|
|
||||||
digit diga, digb;
|
digit diga, digb;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue