Understanding n-bit and m-bit Numbers

  • Thread starter Thread starter Bourbon daddy
  • Start date Start date
  • Tags Tags
    Bit Numbers
Click For Summary

Discussion Overview

The discussion revolves around understanding the memory requirements for storing results of operations involving n-bit and m-bit numbers in the context of embedded systems. Participants explore the implications of addition and multiplication of these numbers, as well as the definitions of n-bit and m-bit numbers.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant seeks clarification on the memory size required to hold results from adding and multiplying n-bit and m-bit numbers, expressing uncertainty about the definitions of these terms.
  • Another participant explains that m and n represent integer values, commonly 8, 16, 32, or 64, and notes the importance of distinguishing between signed and unsigned numbers.
  • A different participant introduces a logarithmic approach to determine memory requirements, stating that for addition, the number of bits needed can be calculated using log_2(2^n + 2^m), and for multiplication, it is log_2(2^m * 2^n).
  • One participant confirms understanding after assigning specific values to n and m, indicating that the calculations align with their expectations.

Areas of Agreement / Disagreement

Participants generally agree on the definitions of n-bit and m-bit numbers and the methods for calculating memory requirements, but there is no consensus on the treatment of signed versus unsigned numbers, and the discussion remains exploratory.

Contextual Notes

The discussion does not address the implications of signed versus unsigned integers in detail, which may affect the calculations presented. Additionally, the assumptions regarding the operations and their results are not fully explored.

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!
 

Similar threads

Replies
1
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · 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