Skip to content

Commit 3e3e9f3

Browse files
committed
Issue #28553: Fix logic error in example code of int.to_bytes doc.
1 parent 04f17f1 commit 3e3e9f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class`. In addition, it provides a few more methods:
485485
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
486486
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
487487
>>> x = 1000
488-
>>> x.to_bytes((x.bit_length() // 8) + 1, byteorder='little')
488+
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
489489
b'\xe8\x03'
490490

491491
The integer is represented using *length* bytes. An :exc:`OverflowError`

0 commit comments

Comments
 (0)