Hot answers tagged

3

Because dropping $0.11011$ is closer to $0.11$ (difference $0.00011$) than to $1.00$ (difference $0.00101$).


3

While Roberts Frost's answer is perfectly correct there is however one small catch! When engaged in practical computations which seek to obtain an approximation $A$ to the solution $T$ of a complicated equation, then there is a profound difference between the statement $T \approx 1$ and the statement $T \approx 1.0$. In the first case, we implicitly state ...


3

Straightforward binary addition only works for twos-complement representation. Sign-magnitude represenation is more complicated, which is why nobody uses it.


3

The numbers you want are of the form $$\sum_{n=1}^k\frac{\alpha_n} {2^n}, $$ where $\alpha_n\in \{0,1\} $. We can rewrite as $$ \frac {\sum_{n=1}^k{\alpha_n}\,2^{k-n}} {2^n} =\frac {\sum_{n=1}^k{\alpha_n}\,2^{k-n}5^n} {10^n} . $$ As the numerator is a multiple of five, the decimal expression will always end in five.


2

You can do this with simple arithmetic You have 2000 elements The largest list you'll get after splitting is then 1000 elements Split again and get 500 Split again and get 250 Split again and get 125 Split again and get 63 (worst case) Split again and get 32 Split again and get 16 Split again and get 8 Then 4 Then 2 Then you compare once more And maybe ...


2

Let's approximately model the digits of a number in positional notation with coprime bases as independent random variables, and likewise for the number's residues with respect to powers of different primes, with mutual conditional independence. (I think you could make this more rigorous by uniformly randomly selecting a number between $1$ and $N$ and taking ...


2

First of all your differences are wrong: 0.101 - 0.10 = 0.001 etc. Second rounding to nearest must be completed with a tie breaking rule if there are two representable numbers with the same difference to the number to be rounded; in your case both candidate numbers are $\pm 1/8$ from the original number: 0.101 - 0.10 = 0.001 = 1/8 0.101 - 0.11 = -0.001 = ...


2

Yes it's exactly the same system. The only restriction on decimal relative to binary is no digits 2-9. As per your proof, removing a trailing zero is always equivalent to subtracting zero and therefore has no effect.


2

Calculate the average of $0.110$ and $0.111$, by adding them and dividing the result by $2$ (keep in mind that it is binary), and see that you get $0.1101$.


1

Suppose you have a 11-bit binary number $a_1a_2\dotsm a_{11}$, where each of the $a_i$ is a binary digit (0 or 1). In the normal interpretation of binary numbers, the value of this would be $2^{10}\cdot a_1 + 2^9\cdot a_2 + \dotsb + 2^0\cdot a_{11}$. However, when you're using the offset system, the value is taken to be $2^{10}\cdot a_1 + 2^9\cdot a_2 + ...


1

I will use a decimal analogy here. Let's consider the case of rounding $x=123.45$ to the nearest integer $X$. The round-to-nearest approach requires that the rounded result $X$ is as close to the non-rounded number $x$ as possible. This means $|X-x|\leq\frac{1}{2}=0.5$. That requirement translates to: Round downwards if the leftmost digit of the ...


1

In general it depends on the string. $P_1$ does not depend on your chosen string. It can be expressed as $1-\left(1-2^{-N}\right)^M$. $2^{-N}$ is the probability of matching each element of $B_1$, so $\left(1-2^{N}\right)^M$ is the probability of not matching any of the $M$ elements of the array. Consider for simplicity the case where $M=N=2$. In this ...


1

Short C code: double x = 0.1; long long n = *(long long*)&x; printf("%llX",n); Gives 3FB999999999999A, which is equivalent to: 0011 1111 1011 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1010 For the record, due to the strict aliasing rule, I cannot recommend this programming method.


1

If you round any binary number to three digits after radix point, then each possible number, e.g. $0.000, 0.001, 0.010, 0.011$, etc), differ from the next one by $0.001$. If the truncated part is less than half of that, i.e. $0.0001$, then the number is rounded down: $$0.10001 \approx 0.100$$ If the truncated part is more than half of $0.001$, then the ...


1

Add $1$ in the last place. In your case, add $\frac{1}{8}$ to get the number $1$, which we should write as $(1.00)_2$ to keep the number of significant figures at $3$. EDIT: Adding anything smaller than $1$ in the last place would automatically increase the number of significant figures in the result. Specifially, if we start with $(1.11)_2 \times 2^{-1} = ...


1

\begin{align} 0.1100 &= 2^{-1} + 2^{-2} \\ 0.1101 &= 2^{-1} + 2^{-2} + 2^{-4} \\ 0.1110 &= 2^{-1} + 2^{-2} + 2^{-3} = 2^{-1} + 2^{-2} + 2\cdot2^{-4} \end{align} Therefore, the difference between $0.1100$ and $0.1101$ as well as between $0.1101$ and $0.1110$ is $2^{-4}$, and hence $0.1101$ does indeed lie halfway between the two other numbers.


1

There is a much quicker way of applying the "round to the nearest" rule than by carrying out subtractions. Suppose rounding down gives $a$ and rounding up gives $b$. The "round to the nearest" rule says round to whichever of $a,b$ is nearer. That is unambiguous unless the number is $\frac{a+b}{2}$ which is equidistant. We deal with that case by a ...


1

There is no such fraction, because if $$ A = a_na_{n-1}\dots a_1a_0.a_{-1}a_{-2}\dots a_{-m} $$ is your finite binary representation then the number is $$ A = \sum_{k=-m}^n a_k 2^k $$ and $\frac12=0.5$. When multiplying numbers you can get the lowest digit by taking the lowest digit of the product of the lowest digits of the factors. E.g. the lowest digit ...


1

No (unless you count integers). A nonintegral binary number with terminating representation has the form $$a_m \cdots a_0 . a_{-1} \cdots a_{-n}$$ where $a_m, \cdots, a_{-n+1} \in \{0, 1\}$ and $a_{-n} = 1$, and has value $$2^m a_m + \cdots + 2^{-n + 1} a_{-n + 1} + 2^{-n} .$$ Now, $2^{-n} = \frac{5^n}{10^n}$, and in particular the numerator of this quantity ...


1

Inadvertently, you have asked more than one question. I will only answer the question "if you take the n first natural numbers (without zero), and if you write their representation in binary and if you make the sum of their digits in the binary represention, how much 1, 2, 3, et ceatera, will you find in this list? " which is what you meant to ask anyway. ...


1

You know all of the $x_i$s are either $0$ or $1$. You also, hopefully know that the infinite sum $$ (2^{-1} + 2^{-2} + 2^{-3} + \cdots) = 1 $$ so in your final equation we have $$ x_1\cdot 2^0 + \underbrace{x_2\cdot 2^{-1}+x_3\cdot 2^{-2}}_{\text{ at most }1} = 1.25 $$ Since the right-hand side is larger than $1$, the $x_1\cdot 2^0$ term must be nonzero -- ...


1

After seeing some comments I believe this would be my answer P(X= Beware) = 2/5 P(X= the) = 1/5 P(X = jabberwork) = 1/5 P(X= my) = 0 P(X= son) = 0 Feel free to state whether this is right or wrong


1

When you count up to $2^{32}$, you start counting $1$, $2$, ... then the $2^{32}$th number is $2^{32}$. Since the computer has to store the number $0$ in an unsigned int, it is actually starting to count with $0$, then $1$ and so on. That means that the $n$th number for the computer is, in fact, $n-1$. Hence, the biggest number it can store, the $2^{32}$th ...


1

Let's start with some powers of $2$: $2^0 = 1$ $2^1 = 2$ $2^2 = 4$ $2^3 = 8$ $2^4 = 16$ $2^5 = 32$ We need to write out $23$, so this is enough powers of $2$. Start with the highest power of $2$ that is equal to or less than the number. This is $16$. So write a $1$ down and subtract it out: $23-16 = 7$. The next highest power, $8$, is greater than ...


1

"On the maximum number of distinct factors of a binary string" (also here), by Jeffrey Shallit, proves that the answer (the attained maximum number of distinct factors of a length-$n$ binary string) is $$\binom{n-k+1}{2}+2^{k+1}-1,$$ where $k$ is the unique integer such that $$2^k + k - 1\ \le\ n\ \lt\ 2^{k+1}+(k+1)-1.$$ (This counts the empty string as a ...



Only top voted, non community-wiki answers of a minimum length are eligible