Programming-Idioms

History of Idiom 76 > diff from v29 to v30

Edit summary for version 30 :

Version 29

2015-10-29, 14:05:16

Version 30

2015-10-31, 14:27:13

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
x = 0xFF
s = '{:b}'.format(x)
Doc URL
https://docs.python.org/3/library/string.html#formatstrings
Origin
https://docs.python.org/3/library/string.html#formatstrings