The bin()
function is used to convert an integer number to a binary string (preceded by “0b”). The binary notation is the representation of integers in base 2, the notation only uses the digits 0 and 1 .
The bin()
function takes an integer argument, and returns the corresponding binary representation of the decimal number.
bin(integer)
Examples:
bin(1)
//'0b1'
bin(2)
//'0b10'
bin(4)
//'0b100'
bin(15)
//'0b1111'
bin(50)
//'0b110010'
bin(64)
//'0b1000000'