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 <rep...@bugs.python.org>
<http://bugs.python.org/issue31079>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to