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.

作者 mark.dickinson
收信人 fredrikj, loewis, mark.dickinson, rhettinger, terry.reedy, vstinner
日期 2008-10-14.19:29:01
SpamBayes Score 8.227305e-06
Marked as misclassified
Message-id <1224012544.13.0.0870547921852.issue3439@psf.upfronthosting.co.za>
In-reply-to
内容
One more minor deficiency in the patch: it gives incorrect results for 
very large integers.  For example, on a 32-bit build of the trunk:

>>> x = 1 << 2**31-1
>>> x <<= 2**31-1
>>> x.numbits()  # expect 4294967295
4294967295L
>>> x <<= 2
>>> x.numbits()  # expect 4294967297
4294967295L

It would be nicer if the OverflowError from _PyLong_NumBits were 
propagated, so that the second case raises OverflowError instead of giving 
an incorrect result.

Alternatively, in case of OverflowError one could recompute numbits 
correctly, without overflow, by using Python longs instead of a C size_t;  
but this would mean adding little-used, and probably little-tested, extra 
code for what must be a very rare special case.  Probably not worth it.
历史
日期 用户 动作 参数
2008-10-14 19:29:04mark.dickinson修改recipients: + mark.dickinson, loewis, rhettinger, terry.reedy, vstinner, fredrikj
2008-10-14 19:29:04mark.dickinson修改messageid: <1224012544.13.0.0870547921852.issue3439@psf.upfronthosting.co.za>
2008-10-14 19:29:01mark.dickinson链接issue3439 messages
2008-10-14 19:29:01mark.dickinson创建