Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python decimal number into 8 bit binary

>>> print(bin(160))  # This version gives the 0b prefix for binary numbers.
0b10100000
>>> print(format(160,'08b'))  # This specifies leading 0, 8 digits, binary.
10100000
>>> print('{:08b}'.format(160)) # Another way to format.
10100000
>>> print(f'{160:08b}')  # Python 3.6+ new f-string format.
10100000
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #decimal #number #bit #binary
ADD COMMENT
Topic
Name
3+2 =