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

1 Answer

0 votes
const num:number = 19;
 
console.log(("00000000" + num.toString(2)).substr(-8));

 
 
  
 
/*
run:
 
"00010011" 
 
*/

 



answered Jan 12, 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
...