Message279641
https://docs.python.org/3/library/stdtypes.html#int.to_bytes
To convert an int to the exact number of bytes required, the docs recommend "x.to_bytes((x.bit_length() // 8) + 1, ...)". This is incorrect when length is a multiple of 8, e.g. 296.
The correct way is "x.to_bytes((x.bit_length() + 7) // 8, ...)". |
|
Date |
User |
Action |
Args |
2016-10-29 00:08:04 | Ofekmeister | set | recipients:
+ Ofekmeister, docs@python |
2016-10-29 00:08:04 | Ofekmeister | set | messageid: <1477699684.07.0.61979939957.issue28553@psf.upfronthosting.co.za> |
2016-10-29 00:08:04 | Ofekmeister | link | issue28553 messages |
2016-10-29 00:08:03 | Ofekmeister | create | |
|