We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04f17f1 commit 3e3e9f3Copy full SHA for 3e3e9f3
Doc/library/stdtypes.rst
@@ -485,7 +485,7 @@ class`. In addition, it provides a few more methods:
485
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
486
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
487
>>> x = 1000
488
- >>> x.to_bytes((x.bit_length() // 8) + 1, byteorder='little')
+ >>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
489
b'\xe8\x03'
490
491
The integer is represented using *length* bytes. An :exc:`OverflowError`
0 commit comments