Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Question: Use binary coded GA(Genetic algorithms), your problem is to find vector with real numbers $\in [0,5]$ and you want your answer at least to three decimal places(0.001).

a) How many bits you need to represent one variable

b) the dimension of your problem is 10 or you optimize ten variables. How many integers( 16 or 32 bits) you need when programming the problem, in case you use bit-fields, in which you have reserved for each variable the bits it exactly needs?

share|cite|improve this question
There are 5001 possible different values of each variable. What is the smallest $n$ such that $2^n$ is at least 5001? – Henning Makholm Feb 13 '12 at 16:37
$5001<2^{13}$, but what it has to do with the problem a)? Do you mean that you need 13 bits( what is bit?) to represent one variable? – alvoutila Feb 13 '12 at 16:45
Bit is a binary digit. It can store one of 2 values: 0 and 1. By using combinations of 0 & 1, you can represent any number. For instance, 7 in Binary is 0111. – Inquest Feb 13 '12 at 16:47
No, this isn't "my problem". Do your own homework. – user5137 May 24 '12 at 16:31
up vote 1 down vote accepted

Since the problem is still open, let me take a shot at it.

For one variable, if you store the integer part separately and the decimal part separately, you need $3$ bits for real numbers $\in [0,5]$ and the decimal part could be $0.001$ upto $0.999$ (since your condition was three decimal places). Which means the decimal part storage needs $$\left\lceil log_2 \hspace{4pt}999 \right\rceil = 10 $$

Therefore for a single variable you need $3$ bits for real part and $10$ bits for decimal part.

For part b, if you are optimizing $10$ variables, it depends if what kind of arithmetic or computation you have with those variables. If multiplication and exponents are also involved, you have to know the bounds of those computation, then one can make a reasonable justification.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.