This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients fredrikj, loewis, mark.dickinson, rhettinger
Date 2008-08-14.09:47:09
SpamBayes Score 5.257902e-05
Marked as misclassified No
Message-id <>
One possible fix would be to compute the absolute value
of n as an unsigned long. I *think* the following is
portable and avoids any undefined behaviour coming
from signed arithmetic overflow.

unsigned long absn;
if (n < 0)
	absn = 1 + (unsigned long)(-1-n);
	absn = (unsigned long)n;

Might this work?

Perhaps it would also be worth changing the tests
in test_int from e.g.

self.assertEqual((-a).numbits(), i+1)


self.assertEqual(int(-a).numbits(), i+1)

This would have caught the -LONG_MAX error.
Date User Action Args
2008-08-14 09:47:11mark.dickinsonsetrecipients: + mark.dickinson, loewis, rhettinger, fredrikj
2008-08-14 09:47:11mark.dickinsonsetmessageid: <>
2008-08-14 09:47:10mark.dickinsonlinkissue3439 messages
2008-08-14 09:47:10mark.dickinsoncreate