Understanding n-bit and m-bit Numbers

  • Thread starter Thread starter Bourbon daddy
  • Start date Start date
  • Tags Tags
    Bit Numbers
Click For Summary
The discussion centers on understanding the memory requirements for storing results from operations involving n-bit and m-bit numbers in embedded systems. It clarifies that an n-bit number represents a binary integer with 2^n possible values, while m-bit numbers follow the same principle. For addition, the required memory size is determined by calculating log_2(2^n + 2^m), which rounds up as necessary. If both numbers are of the same size (n = m), the result requires m + 1 bits. For multiplication, the memory needed is calculated using log_2(2^m * 2^n), resulting in m + n bits. The discussion emphasizes the importance of understanding these calculations for different operations and the distinction between signed and unsigned integers, although the latter is not explicitly addressed in the calculations.
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.
 
Technology 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!
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
1
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K