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 141 views
1 answer 122 views
1 answer 117 views
1 answer 118 views
1 answer 118 views
1 answer 124 views
...