If you are multiplying two binary numbers, one with n number of bits and one with m number of bits, how many bits is the product? For ex., if I multiply a binary number of 6 bits and a binary number of 8 bits, how many bits will the product be?
When you multiply two numbers, the number of bits in the product cannot be less than max(m,n) and cannot be more than (m+n). (Unless one of the two numbers is a 0).
In your example, with m = 6 and n = 8.
The minimum number of bits in the product will be 8 and the maximum will be 14.
Looking at this question in terms of functions, you can use the logarithm base 2. So for example if we have two numbers a and b (and for the sake of clarity lets say a has n bits and b has m bits.) You would arrive at these values by taking the log_2 of both numbers:
log_2(a) = n ; log_2(b) = m
Now if you want the number of bits of the product, you can use a property of the logarithm:
log_2(a*b) = log_2(a) + log_2(b)
So you get the number of bits of the product! This will be an upper bound for your size, but it works quite well.
For m and n, minimum is m+n-1
and maximum is m+n
.
Therefore, 8 and 6 give 13 and 14 respectively.
© 2022 - 2024 — McMap. All rights reserved.