How to print the bits of an integer in 8 bit format with JavaScript

1 Answer

0 votes
const num = 17;

console.log(("00000000" + num.toString(2)).substr(-8));




/*
run:

"00010001"

*/

 



answered Jan 11, 2023 by avibootz
edited Jan 12, 2023 by avibootz

Related questions

1 answer 124 views
1 answer 110 views
1 answer 101 views
1 answer 104 views
1 answer 102 views
1 answer 110 views
...