[issue31079] mathematically wrong results from int and long bit_length methods

2017-07-30 Thread vinsci
vinsci added the comment: >>> (0).bit_length.__doc__ "int.bit_length() -> int\n\nNumber of bits necessary to represent self in binary.\n>>> bin(37)\n'0b100101'\n>>> (37).bit_length()\n6" The library documentation has clearly been written in

[issue31079] mathematically wrong results from int and long bit_length methods

2017-07-30 Thread vinsci
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,