mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #28553: Fix logic error in example code of int.to_bytes doc.
This commit is contained in:
commit
a99cdb21a7
1 changed files with 1 additions and 1 deletions
|
@ -485,7 +485,7 @@ class`. In addition, it provides a few more methods:
|
||||||
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
|
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
|
||||||
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
|
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
|
||||||
>>> x = 1000
|
>>> x = 1000
|
||||||
>>> x.to_bytes((x.bit_length() // 8) + 1, byteorder='little')
|
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
|
||||||
b'\xe8\x03'
|
b'\xe8\x03'
|
||||||
|
|
||||||
The integer is represented using *length* bytes. An :exc:`OverflowError`
|
The integer is represented using *length* bytes. An :exc:`OverflowError`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue