Understanding n-bit and m-bit Numbers

  • Thread starter Thread starter Bourbon daddy
  • Start date Start date
  • Tags Tags
    Bit Numbers
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 5K views
Bourbon daddy
Messages
24
Reaction score
0
Hi guys,

I sure this is an astonishingly dumb question, but I am new to embedded systems, so don't be too harsh.

I am taking embedded systems in final year at uni and working through some introductory tutorial sheets.

One question asks;

-If two n-bit numbers are added together, what memory size is required to hold the result?

-If two n-bit numbers are multiplied together, what memory size is required to hold the result?

-If an n-bit number is multiplied with an m-bit number, what memory size is required to hold the result?

What is an n-bit number and how does it differ to an m-bit number? I assume they are just to variable integers, and at first I presumed they could just be any size, but I would not know how to express the answer if this were the case.
 
Physics news on Phys.org
m and n just represent some integer value. For a computer, the common values would be 8, 16, 32, 64. What's missing from these questions is if the numbers are signed or unsigned.
 
The best way to understand this is through logs (in base 2).

If you have n bits for a word then you have 2^n possible values.

For addition this means you need to calculate log_2(2^n + 2^m) and round up where necessary. If m = n then you have the situation where log_2(2^m + 2^n) = log_2(2*2^m) = log_2(2^(m+1)) = m+1 bits.

For multiplication you have log_2(2^m * 2^n) = log_2(2^(m+n)) = m + n bits.

You can use the same sort of rules for all other operations to find the number of bits.
 
Ok, that makes sense, I have just assigned a number to n and m as it makes it easier for me to follow the logic and it calculates as you would expect.

Thanks for the help guys, much appreciated!