Respuesta :
Note that powers of 2 can be written in binary as
[tex]2^0=1_2[/tex]
[tex]2^1=10_2[/tex]
[tex]2^2=100_2[/tex]
and so on. Observe that [tex]n+1[/tex] digits are required to represent the [tex]n[/tex]-th power of 2 in binary.
Also observe that
[tex]\log_2(2^n)=n\log_22=n[/tex]
so we need only add 1 to the logarithm to find the number of binary digits needed to represent powers of 2. For any other number (non-power-of-2), we would need to round down the logarithm to the nearest integer, since for example,
[tex]2_{10}=10_2\iff\log_2(2^1)=\log_22=1[/tex]
[tex]3_{10}=11_2\iff\log_23=1+(\text{some number between 0 and 1})[/tex]
[tex]4_{10}=100_2\iff\log_24=2[/tex]
That is, both 2 and 3 require only two binary digits, so we don't care about the decimal part of [tex]\log_23[/tex]. We only need the integer part, [tex]\lfloor\log_23\rfloor[/tex], then we add 1.
Now, [tex]2^9=512<1024=2^{10}[/tex], and 999 falls between these consecutive powers of 2. That means
[tex]\log_2999=9+\text{(some number between 0 and 1})[/tex]
which means 999 requires [tex]\lfloor\log_2999\rfloor+1=9+1=10[/tex] binary digits.
Your question seems to ask how many binary digits in total you need to represent all of the numbers 0-999. That would depend on how you encode numbers that requires less than 10 digits, like 1. Do you simply write [tex]1_2[/tex]? Or do you pad this number with 0s to get 10 digits, i.e. [tex]0000000001_2[/tex]? In the latter case, the answer is obvious; [tex]1000\times10=10^4[/tex] total binary digits are needed.
In the latter case, there's a bit more work involved, but really it's just a matter of finding how many number lie between successive powers of 2. For instance, 0 and 1 both require one digit, 2 and 3 require two, while 4-7 require three, while 8-15 require four, and so on.
[tex]2^0=1_2[/tex]
[tex]2^1=10_2[/tex]
[tex]2^2=100_2[/tex]
and so on. Observe that [tex]n+1[/tex] digits are required to represent the [tex]n[/tex]-th power of 2 in binary.
Also observe that
[tex]\log_2(2^n)=n\log_22=n[/tex]
so we need only add 1 to the logarithm to find the number of binary digits needed to represent powers of 2. For any other number (non-power-of-2), we would need to round down the logarithm to the nearest integer, since for example,
[tex]2_{10}=10_2\iff\log_2(2^1)=\log_22=1[/tex]
[tex]3_{10}=11_2\iff\log_23=1+(\text{some number between 0 and 1})[/tex]
[tex]4_{10}=100_2\iff\log_24=2[/tex]
That is, both 2 and 3 require only two binary digits, so we don't care about the decimal part of [tex]\log_23[/tex]. We only need the integer part, [tex]\lfloor\log_23\rfloor[/tex], then we add 1.
Now, [tex]2^9=512<1024=2^{10}[/tex], and 999 falls between these consecutive powers of 2. That means
[tex]\log_2999=9+\text{(some number between 0 and 1})[/tex]
which means 999 requires [tex]\lfloor\log_2999\rfloor+1=9+1=10[/tex] binary digits.
Your question seems to ask how many binary digits in total you need to represent all of the numbers 0-999. That would depend on how you encode numbers that requires less than 10 digits, like 1. Do you simply write [tex]1_2[/tex]? Or do you pad this number with 0s to get 10 digits, i.e. [tex]0000000001_2[/tex]? In the latter case, the answer is obvious; [tex]1000\times10=10^4[/tex] total binary digits are needed.
In the latter case, there's a bit more work involved, but really it's just a matter of finding how many number lie between successive powers of 2. For instance, 0 and 1 both require one digit, 2 and 3 require two, while 4-7 require three, while 8-15 require four, and so on.