Andy
Andy

Reputation: 15

Base Conversions between 10 and 2

Suppose you have a 20 digit base 10 positive integer, and you want to represent it in base 2. How many bits are necessary? Why?

I tried : log(2)10 * 10 +1 =66.44 + 1 = 67.44 Then I rounded down to 67 as a final answer

Upvotes: 1

Views: 46

Answers (1)

Zhuoran He
Zhuoran He

Reputation: 983

The biggest 20-digit number in base 10 is 10^20-1 (or 20 nines). This number is between 2^66 and 2^67. Since 2^66 is 1 followed by 66 zeros in base 2, it is a 67-digit number. 2^67 is the smallest 68-digit number in base 2. Since 10^20-1 is smaller than that, it is only 67 digits long in base 2. Therefore, a 20-digit number in base 10 is at most 67 digits long in base 2.

Upvotes: 1

Related Questions