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 228 views
1 answer 193 views
1 answer 198 views
1 answer 195 views
1 answer 184 views
1 answer 190 views
...