[New-bugs-announce] [issue31079] mathematically wrong results from int and long bit_length methods
vinsci
report at bugs.python.org
Sun Jul 30 12:27:18 EDT 2017
New submission from vinsci:
It takes as many bits to store the number 0 as the number 1, but the implementation claims it takes no bits at all to store a 0.
>>> (1).bit_length() == (0).bit_length() and True or False
False
It takes one extra bit to store the sign for negative numbers, but this isn't reflected in the implementations.
>>> (-1).bit_length() == 1 + (1).bit_length() and True or False
False
----------
components: Library (Lib)
messages: 299500
nosy: vinsci
priority: normal
severity: normal
status: open
title: mathematically wrong results from int and long bit_length methods
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31079>
_______________________________________
More information about the New-bugs-announce
mailing list