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

1 Answer

0 votes
const num:number = 84721;
 
console.log(("0000000000000000" + num.toString(2)).substr(-16));

 
 
  
 
/*
run:
 
"0100101011110001" 
 
*/

 



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

Related questions

1 answer 125 views
1 answer 112 views
1 answer 148 views
2 answers 142 views
1 answer 117 views
1 answer 100 views
...