-2

I have a problem where there is a statement that says there is an ID 'n' which is non-negative integer of length 'k' in base 'b'? I dont understand what they are trying to say by this? Is it something to do with log? like log with base 'b' or something? can someone please explain with an example?

AviG88
  • 3
  • 2
    Length just refers to the number of digits. It is roughly $\log_b(n)$, as you surmise. – lulu Jan 01 '21 at 00:41
  • The number of digits in base $10$, for example, is $L(n)=\lfloor \log_{10}(n)\rfloor+1$. – lulu Jan 01 '21 at 00:45
  • n=210022, k=6, b=3 if k is the length here does it mean that 6= log3(210022)+1 .? – AviG88 Jan 01 '21 at 00:48
  • Don't leave off the floor. We have $210022_3=575_{10}$, and $\log_3 (575)=5.783996872$ so the (obvious generalization of) my formula would give the length as $5+1=6$ which is correct. – lulu Jan 01 '21 at 00:52
  • To be clear, it's $6 = \lfloor \log_3(210022_3)\rfloor + 1$. – peterwhy Jan 01 '21 at 00:52
  • @lulu please you could you provide me a link or something where I can understand this? I am not sure where the 575 base 0 came from ? How is this calculation happening? Sorry I am not good at math – AviG88 Jan 01 '21 at 00:57
  • It's $575_{10}$ not base $0$. In order to compute the log, I found it easier to convert your number to base $10$. That's $2+2\times 3+0\times 3^2+0\times 3^3+1\times 3^4+2\times 3^5=575_{10}$. – lulu Jan 01 '21 at 00:59
  • here is a reference for the base $10$ formula. – lulu Jan 01 '21 at 01:01
  • Wolfram Alpha lets you convert numbers between bases quite easily. – lulu Jan 01 '21 at 01:02
  • @lulu thanks for all the resources. I am still a little confused though. Il have to do some reading on this – AviG88 Jan 01 '21 at 01:05

1 Answers1

0

It means it has $k$ digits. Nothing more nothing less.

You can use logs and exponents to estimate the size of a base $b$ number with $k$ digits by the following reasoning.

A $1$ digit number Can be as small as $1$ or as large as $b-1$. So if your value is between $1$ and $b-1$ it has $1$ digit.

A $2$ digit number can be as small as $10_b = b$ or large as $[b-1][b-1]_b = (b-1)\cdot b + (b-1) = b^2 -1$. so if you value is between $b$ and $b^2-1$ it will have $2$ digits.

A $3$ digit number can be as small as $100_b = b^2$ or as large as $[b-1][b-1][b-1]_b = (b-1)\cdot b^2 + (b-1)\cdot b + (b-1) = b^3 - 1$. so if your value is between $b^2$ and $b^3-1$ it will have $3$ digits.

ANd generalizing. A $k$ digit number can be as small as $100....0_b = b^{k-1}$ or as large as $[b-1][b-1]....[b-1] = b^{k} -1$.

so if you want to know how many digits a number will have in base $b$ we do the following.

If we want to know how many digits $M$ has, we say. Let $M$ have $k$ digits. To solve for $K$ we figur that $b^{k-1} \le M \le b^{k+1} -1< b^{k}$.

so $\log_b b^{k-1} \le \log_b M < \log_b b^{k}$ so

$k - 1\le \log M < k$. And that is how we solve for $k$ and find out how many digits $M$ will have in base $b$.

For example if we wante to figure out how many digits $3456$ will have in base $6$ we figure if it has $k$ digits then $6^{k-1} \le 3456 < 6^{k}$ so $k-1 \le \log_6 3456 = \frac {\ln 3456}{\ln 6} < k$. so $k-1 \le 4.35 < k$ so $k = 5$. It will have $5$ digits.

And indeed $6^4 = 1296 < 3456 < 6^5= 7776$

so $3456 = 2*1296 + 864$. And $6^3 = 216$ and $3456 = 2*1296 + 4*216 + 0$. (That was a complete coincidence! I didn't plan it.) So $3456_{10} = 24000$ has $5$ digits.

=======

Alternatively we can go the other way.

If you have $243253242_6$ how many digits will it have in base $10$.

well, $M = 243253242$ has $9$ digits so $6^8 \le M \le 6^9 -1$.

$\log_{10} 6^8 = 8\log_{10} 6 \approx 6.2$ and $\log_{10} 6^9 = 9\log_{10} 6\approx 7$ so if $243253242_6$ has $k$ digits then $k- 1=6$ and it will have $7$ digits.

And indeed $2*6^8 =3359232_{10} < M < 2*6^8 + 5*6^7 = 5318784_{10}$ which has $7$ digits.

fleablood
  • 130,341