]> granicus.if.org Git - python/commitdiff
Issue #28553: Fix logic error in example code of int.to_bytes doc.
authorINADA Naoki <songofacandy@gmail.com>
Mon, 31 Oct 2016 08:41:47 +0000 (17:41 +0900)
committerINADA Naoki <songofacandy@gmail.com>
Mon, 31 Oct 2016 08:41:47 +0000 (17:41 +0900)
Doc/library/stdtypes.rst

index 2587ac85b0b2a8cc41d3c3230d1966146b462907..5936c6845912bd07f286cd35abd3ad0ce4bef767 100644 (file)
@@ -485,7 +485,7 @@ class`. In addition, it provides a few more methods:
         >>> (-1024).to_bytes(10, byteorder='big', signed=True)
         b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
         >>> 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'
 
     The integer is represented using *length* bytes.  An :exc:`OverflowError`