Contact: aviboots(AT)netvision.net.il
42,200 questions
54,908 answers
573 users
function totalBits(num) { return Math.floor(Math.log2(num)) + 1; } let n = 12; // 1100 console.log(totalBits(n)); n = 386; // 1 1000 0010 console.log(totalBits(n)); /* run: 4 9 */