How to print bits in JavaScript

1 Answer

0 votes
const n = 2871;

console.log(String(n.toString(2)).padStart(16, '0'));

 
 
/*
run:
 
0000101100110111
 
*/

 



answered Apr 4, 2024 by avibootz
...