New answers tagged

0

Martin, I believe that you need to use a floating point convention to represent the decimal number. You can refer to the article https://en.wikipedia.org/wiki/IEEE_floating_point which shows a number of formats. I don't understand the significance of representing the value in octal verses binary because the base you choose to represent the value is ...


0

The range is from $-2^{15}$ to $2^{15}-1$.


0

Refer to the 4-bit example in the above comment. Standard binary to Gray code: $a\mid b\mid c\mid d\qquad\to\qquad p\mid q\mid r\mid s$ where $p=(a)$ $q=(a\not\equiv b)$ $r=(b\not\equiv c)$ $s=(c\not\equiv d)$ $====================$ Gray code to Standard binary: $p\mid q\mid r\mid s\qquad\to\qquad a\mid b\mid c\mid d$ where $a=(p)$ $b=(p\not\equiv q)$ ...


0

When using 2-complementary, the range of 8 bits integer is $-128<= n <= 127$. When you have a number 0xE5, once it is binary form, it is a negative number. The two's complentary of this number is a positive number, and add negative sign to it, that is the decimal number (negative) for 0xE5 for the system using two's complementary. once you flip bits, ...


0

When you subtract two signed numbers, the Carry flag is irrelevant; the Overflow flag is all that counts. The Carry flag is for unsigned integer operations. So there is only ever one bit to worry about.


1

You can find many explanations of the IEEE-754 format on the Web. In short, each 32-bit single-precision floating-point number consists of three parts (we assume that the bits numbering begins from zero): sign, bit 31 exponent, bits 30-23 (eight bits in total) significand (or "mantissa"), bits 22-0 (twenty three bits in total) However, in your case the ...


0

Overflow and carry out are philosophically the same thing. Both indicate that the answer does not fit in the space available. The difference is that carry out applies when you have somewhere else to put it, while overflow is when you do not. As an example, imagine a four bit computer using unsigned binary for addition. If you try to add $1010_2+111_2$ ...


1

As BrianO explains in his answer, any rational number that can be written with a terminating binary expansion has two distinct binary representations: one in which the binary representation terminates in a $1$, and one in which the binary representation terminates in $0\overline{1}$. So the question in the OP reduces to: which rational numbers in $[0,1)$ ...


1

Partial answer: Any nonzero rational in $[0,1)$ with a terminating representation has two binary expansions. Suppose $x\in (0,1)$ is rational, $x\ne 0$, and $$ x = 0.d_1 \dotsm d_n $$ for binary digits $d_i$. As $x\ne 0$, we have $d_n = 1$: $$ x = 0.d_1 \dotsm d_{n-1} 1 $$ But now it's easy to see and show that $$ x = 0.d_1 \dotsm d_{n-1} 0 \overline{1} ...


0

$$ 0.\overline{0011}=\sum_{k=0}^\infty \left(\frac1{2^3}+\frac1{2^4}\right)\frac1{2^{4k}}=\sum_{k=0}^\infty \frac3{16}\cdot\frac1{16^{k}}=\frac3{16}\cdot\frac1{1-1/16}=\frac15. $$


2

You can use the same technique as with repeating decimals: $$\begin{array}{rcrl}x &=& 0.\overline{0011}\\ 10000_2 x &=& 11.\overline{0011}\\ 1111_2x &=& 11.0000\\ x&=&\dfrac{11_2}{1111_2}&=\dfrac{3}{15}=\dfrac15\end{array}$$


0

When you represent a number in decimal scientific notation, the base of the exponent is $10$, so $1E35=1\cdot 10^{35}$. In binary, the base is $2$, so you are trying to solve $1\cdot 10^{35}=m2^e$ where $1 \lt m \lt 10_2$ is the mantissa and $e$ is an integer exponent. To find $e$ we can take logs: $$1 \cdot 10^35 = m2^e\\ 35 \log_2(10)=e+ \log_2 ...


0

The probability of a binary word of length $N$ occurring at position $i$ within another binary word of length $M\ge N$, where $1\le i\le M-N+1$, is $$P(N_i)=\frac{1}{2^N}$$ The probability of not finding word $N$ at position $i$ within word $M$ is $$P(\lnot N_i)=1-\frac{1}{2^N}$$ The probability of not finding word $N$ anywhere within word $M$ is $$P(\lnot ...


0

The fact that $$ 2^{10} = 1024 \approx 1000 = 10^3 $$ tells you that every ten binary digits need just over three decimal digits. Your question asks about exactly how many more than three (3.32...). The other answers (using logarithms, all good) identify the source of that number.


1

Taken from comments: You have correctly proved that $\sum_{i=0}^{n-1} 2^i = 2^n - 1.$ To complete the proof of the initial claim, you should elaborate on why $\sum_{i=0}^{n-1} 2^i $ is the greatest number you can make with $n$ bits.


2

You can use strong induction. $1=2^03^0$ is the base case. Now assume all numbers up through $m$ can be represented. If $m+1$ is even, take the representation of $\frac 12(m+1)$ and increase all the $x$'s by $1$. If $m+1$ is an odd multiple of $3$, take the representation of $\frac 13(m+1)$ and increase all the $y$'s by $1$. If $m+1$ is coprime to $6$, ...


1

No, each nonnegative integer has one and only one binary representation. (That is, if we don't care about representations that only differ in how many leading zeroes they have). Suppose you have two different bit strings and we want to prove that they represent different integers. Let's look at the leftmost position where the two bit strings differ; there ...


1

No. If we use $n$ bits to represent unsigned integers in the range $0,1,\ldots, 2^n-1$ then each bit pattern corresponds to exactly one of these integers and vice versa. Assume that some integer $k\ge 0$ allowed two distinct patterns of $n$ bits, where $2^n>k$. Among those integers we let $k$ be the minimal one. And among all matching numbers of bits, ...


0

It's just the way the positional system works. For example consider the number $101$ (no base mentioned). The positional system works so that each digit in the number have different "weight". If it's base ten the first one has weight hundred, the zero has weight ten and the last one has weight one. The number is then the sum of the digits multiplied with ...


0

In the number system to base $n$, the number represented by the digits $$a_ra_{r-1}\dots a_1$$ is $$a_rn^{r-1}+a_{r-1}n^{r-2}+\dots a_2n+a_1$$ If we set $a_k=0$ except for $a_2=1$ this sum is equal to $n$ so that $10=n$ in base $n$.


1

I'm not sure what you mean. In 'why 10 in any base number system write as 10' what is the supposed base of each '10'...? For example in base 2, 'two' is written as 10, but it is not decimal 'ten'; it's two. We use subscript to denote a base (with a common convention that the base in subscript is in decimal), so: two in binary is $2 = 10_2$, ten in decimal ...


1

$\color\green1\color\red0\color\red0\color\red0\color\red0\color\red0\color\red0\color\red0\color\green1\color\green1\color\red0.\color\red0\color\green1\color\green1=$ $\color\green1\cdot2^{10}+$ $\color\red 0\cdot2^{ 9}+$ $\color\red 0\cdot2^{ 8}+$ $\color\red 0\cdot2^{ 7}+$ $\color\red 0\cdot2^{ 6}+$ $\color\red 0\cdot2^{ 5}+$ $\color\red ...


2

Imagine you write the $n$ zeros and the $n$ ones along a line. The possible configurations can be created by permuting them in all possible ways. There are $(2n)!$ permutations of $2n$ digits. However, permutations that only exchange ones among themselves do not produce new configurations. You must discard them. There are $n!$ permutations among the $n$ ...


0

This is the number of trailing zeroes at the end of $5^p/2$ (integer division). In mathematical terms, it is the multiplicity of the factor $2$ in the prime decomposition of this number. In programming, you will shift right until you get an odd number, and count the shifts.


2

As described in the comments: the answer, let's call it $f(n)$, is one less than the greatest power of $2$ which divides $5^n-1$. Thus $$f(n)=v_2(5^n-1)-1$$ where, as usual, $v_2(k)$ denotes the greatest power of $2$ dividing $k$. To compute $v_2(5^n-1)$... first note that this is $2$ if $n$ is odd: indeed $5^n-1=(5-1)(5^{n-1}+\dots+1)$ regardless ...


0

there is nothing wrong, in matlab as in any programming language $\pi$ is represented by a double precision floating number, i.e. a rational number of the form $N 2^{-k}$ where $N,k$ are integers.


1

I always manage to confuse myself with this process since it is not done manually too often, so refer to this handy algorithmic like approach. In both cases, the number we are subtracting is larger in magnitude. $1's$ Complement: Determine the $1's$ complement of the larger number: $00101$ Add the $1's$ complement to the smaller number: $01001 + 00101 = ...


0

Binary format works: 2^^01001 - 2^^11010 -17



Top 50 recent answers are included