Therefore, at most $m+n$ bits are sufficient for the product of the two numbers. Of course, lesser bits might suffice. Also, the sign bit is not included in the computation, and each of $a$, $b$, and $a \cdot b$ might have a separate sign bit.

If you really need to optimize on space, you can check $a$ and $b$ for special cases. Some cases could be:

$a$ or $b$ is $0$: You need 1 bit

$a$ or $b$ is $1$: You need as many bits as the other number

One of the numbers is a power of $2$: It will contain exactly one $1$, say at position $i$ (LSB is position 0). Then, the multiplication is equivalent to left shifting the other number by $i$ bits.

You might think up other special cases if you really need to.

Edit: As pointed out by Sam in the comments, if you impose the restriction that the most significant bit has to be 1 (unless the number itself is 0), you can get a lower bound too.
Since the MSB is 1, we have:
$$a \geq 2^{m-1}$$ and $$b \geq 2^{n-1}$$.
Thus, $$a \cdot b \geq 2^{m + n - 2} = 2^{(m+n-1) - 1}$$

To represent $2^{(m+n-1)-1}$, you require $m+n-1$ bits, and so to represent $a \cdot b$, you need at least $m+n-1$ bits. This leaves the special case when either of the numbers is $0$, and assumes there are no leading 0's in any of the numbers.

As a conclusion, if you know the number of binary digits/bits of your number (as you mention in your question), you are most likely implying that there are no leading $0$'s and the left-most bit is $1$ (exception being when the number itself is 0, where you can simply assign 1 bit for the resulting product). In such a scenario, the product will have either $m+n$ bits or $m+n-1$ bits.

If you require that the leftmost digit of both $a$ and $b$ is one you can get a lower bound using essentially this exact same method
–
SamMDec 20 '12 at 19:05

@Sam Thanks! I did not give the lower bound as the OP needs to allocate memory for an array, and needs an upper bound on the number of bits. But I have edited the answer, as the lower bound shows that unless the product is 0, the number of bits do not have a big range. Also, the lower bound removes the need of the special cases that I mentioned, except for the special case of product being 0. I have edited my answer with the lower bound.
–
PareshDec 20 '12 at 19:46