Tag Info

Hot answers tagged

25

The number of digits of the representation of a positive integer $n$ in base $k$ is $$\ell_k(n) = \lfloor \log_k n \rfloor + 1,$$ and the ratio of the length of a binary representation of a number to its decimal length is $$\frac{\ell_2(n)}{\ell_{10}(n)} = \frac{\lfloor \log_2 n \rfloor + 1}{\lfloor \log_{10} n \rfloor + 1}.$$ For large $n$, the constant ...


6

The number of digits is approximately(never off by more than 1) equal to the log in that base($\log_{10}(x)\approx$ the number of digits of x in base 10). Because of log math, you get: $$\frac{\log_{10}(x)}{\log_2(x)}\approx 3.32193$$


5

You're doing it correctly, but you're missing a step. You know how to obtain the unsigned value, but you're missing the next step that gives you the signed value. Let's call $c$ the unsigned value, $\mathcal{L}$ the bit length and $n$ the signed value. Like Tony, I'm going to assume that a. and c. are supposed to be 8-bit, and b. and d. are supposed to be ...


4

For my answer, I'm going to assume that a. and c. are supposed to be 8-bit, and b. and d. are supposed to be 16-bit. There are just two steps. First, you XOR the number with FF or FFFF, and then you add 1. That's it. So, with F0, you XOR with FF to get 15, and then you add 1 to get 16, so F0 means $-16$. If you're still unsure, you can check with either ...


4

We can define a recursive function that will return $0$ for an even number of binary $1$s and $1$ for an odd number of binary $1$s using these facts: $2k$ has the same number of binary $1$s as $k$ has ($2k$ is obtained from $k$ by appending a $0$ to the binary representation of $k$). $2k+1$ has one more binary $1$ than $k$ has ($2k+1$ is obtained from $k$ ...


2

If you put "two's complement" in the search box, you can find a great many questions and answers describing two's complement. But I'll try to give a quick overview of hexadecimal vs. binary notation and two's complement. Hexadecimal vs. binary Converting between hexadecimal and binary numbers is actually extremely easy. You can do it by hand without any ...


2

A positive integer n has b bits when 2b-1 ≤ n ≤ 2b – 1. so The number of bits required to represent an integer $n$ is : $$\lfloor\log_2 n\rfloor+1$$


2

With a sequence of $0$s and $1$s of length $b$ you can make $2^b$ permutations. Therefore, if you take into account non-negative integers, you can represent numbers up to $2^b - 1$. It follows that a number $n$ needs $\lfloor \log_2 n \rfloor + 1$ bits to be represented. In your case: $$\lfloor \log_2 2^{1000} \rfloor + 1 = 1001$$ $$\lfloor \log_2 3^{1000} ...


1

An interesting, if inefficient way to calculate logs: import string import math import matplotlib.pyplot as plt huge_number = 21**31**3 b10len = len(str(huge_number)) NUMERALS = string.digits + string.lowercase def baseN(num, b): digits = [] while num: digits.append(NUMERALS[num % b]) num = num // b return ...


1

The binary representation of a positive integer $n$ has $\lfloor \log_2 n \rfloor + 1$ digits, i.e., requires that many bits to store; so, for example, the number $3^{1000}$ requires $$\lfloor \log_2 (3^{1000})\rfloor + 1 = \lfloor 1000 \log_2 3 \rfloor + 1 = 1585$$ bits. Of course, if all of the numbers you're working with have the form $a^b$, it's ...


1

The number of zeroes at the end of $n$ in base $k$ notation is the highest power of $k$ that divides $n$. This is very elementary proof. Now, the highest power of $2$ that divides $50!$ can be calculated as: $\sum\limits_{i = 1}^\infty\lfloor\frac{50}{2^i}\rfloor = \lfloor\frac{50}{2}\rfloor + \lfloor\frac{50}{4}\rfloor + \cdots = 25 + 16 + 6 + 3 + 1 = 47$, ...


1

The wording of your hint doesn't make much sense. The closest thing to it seems to be the following: For any sequence $t_1, t_2, \dots, t_n$ in $\{0, 1\}$, try writing a boolean function $f(x_1, x_2, \dots, x_n)$ using and, or, not such that $f(x_1, x_2, \dots, x_n) = 1$ iff $x_1 = t_1, x_2 = t_2, \dots, x_n = t_n$.


1

I could not post above so I am writing here: The total no. of such functions is $2^{2^n}$ because all functions can be expressed. Say you have an arbitrary $g: B_n \rightarrow \{0, 1\}$. List all strings in $B_n$ on which $g$ takes the value $1$. Then $g$ is simply the disjunction of all characteristic functions of these strings as explained above.


1

A number of useful functions on the integers (or tuples of integers) have this property: to compute the last $N$ digits of the result you only need the last $f(N)$ digits of the input where $f$ is some reasonably slow growing function of $N$. This means it makes sense to evaluate your function on the integers by working from the least significant digit first ...


1

Take $\log _2\left( x \right)$, then multiply by $\log _{10}\left( 2 \right)$ and the answer is 10^whatever you got. So $10^{\log _2\left( x \right)\log _{10}\left( 2 \right)}$ Reason: $\log _b \left( x \right) = \log _b \left( c \right)\log _c \left( x \right) = \frac{{\log _c \left( x \right)}}{{\log _c \left( b \right)}}$


1

Hint(s): If a linear $[n,k,d]$ code exists, than it is equivalent to a linear $[n,k,d]$ code having the generator matrix in the form of $G=[I_k|A]$, where $A$ is a $k * (n-k)$ matrix. In a linear $[n,k,d]$ code, $d(C)=w(C)$. That means that if the minimum distance is $d$, than the minimum weight of any non-zero codeword is $d$ as well. In case you are ...


1

When you are doing arithmetic two's complement, the leftmost bit is $0$ for positive numbers, $1$ for negative numbers. You started with $110101$ (base $2$), which is $53$ (base $10$) when treated as an unsigned number, but you proceeded to treat it as a six-bit number in a two's-complement representation. Since the leftmost bit is $1$, that makes it a ...



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