A large number, 32 digit decimal number is given. How many bit are needed to represent in binary ?
Asked
Active
Viewed 1,114 times
0
-
2Are you familiar with how logarithms relate to the number of digits of a number in a particular base? This is a straightforward application of that fact. – JMoravitz Jun 28 '19 at 14:12
-
sorry sir, I don't know. I am searching that relationship. – Ahmed Nazir Jun 28 '19 at 14:13
-
number of digits is one more than greatest integer of logarithm – J. W. Tanner Jun 28 '19 at 14:15
-
If there is any equation , please explain it. – Ahmed Nazir Jun 28 '19 at 14:16
-
1See this post – J. W. Tanner Jun 28 '19 at 14:17
-
1Answer: 107 bits $$\left\lceil \log_2 99,999,999,999,999,999,999,999,999,999,999 \right\rceil = 107$$ – SlipEternal Jun 28 '19 at 14:23
-
Possible duplicate of How many bits needed to store a number – JMoravitz Jun 28 '19 at 14:32
-
@InterstellarProbe floor and add one instead of using ceiling. Otherwise you'll run into errors when asking about powers of two. $\lceil\log_2(4)\rceil = 2$ but $4$ is represented as $100_2$ in binary requiring three digits, not $2$. – JMoravitz Jun 28 '19 at 14:40
-
The number of base-$b$ digits to represent $n$ is $1+\lfloor\log_b(n)\rfloor$. – robjohn Jun 28 '19 at 14:41
-
@JMoravitz ah, good point! – SlipEternal Jun 28 '19 at 15:05