Understanding n-bit and m-bit Numbers

  • Thread starter Bourbon daddy
  • Start date
  • Tags
    Bit Numbers
In summary, the conversation discusses the memory size required to hold the result of adding or multiplying two n-bit numbers, as well as the difference between n-bit and m-bit numbers. The speaker also mentions that n and m represent integer values, commonly 8, 16, 32, or 64, and that the number of bits needed can be calculated using logarithms. The conversation concludes with the speaker thanking for the help and clarifications.
  • #1
Bourbon daddy
24
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
  • #2
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.
 
  • #3
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.
 
  • #4
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!
 
  • #5


Hi there,

First of all, there is no such thing as a dumb question when it comes to learning something new. It's great that you are taking an interest in embedded systems and working through tutorials to improve your understanding.

To answer your question, an n-bit number refers to a binary number with n digits. This means that it can have a maximum value of 2^n - 1. For example, a 4-bit number can have a maximum value of 15 (2^4 - 1 = 15). On the other hand, an m-bit number would have m digits and a maximum value of 2^m - 1.

Now, let's look at the questions:

- If two n-bit numbers are added together, the result will also be an n-bit number. This means that the memory size required to hold the result will be the same as the memory size required for the two initial numbers. For example, if you add two 4-bit numbers, the result will also be a 4-bit number.

- If two n-bit numbers are multiplied together, the result will be a 2n-bit number. This means that the memory size required to hold the result will be double the memory size of the initial numbers. For example, if you multiply two 4-bit numbers, the result will be an 8-bit number.

- If an n-bit number is multiplied with an m-bit number, the result will be an (n+m)-bit number. This means that the memory size required to hold the result will be the sum of the memory sizes of the two initial numbers.

I hope this clarifies the concept of n-bit and m-bit numbers for you. Keep up the good work in your studies!
 

What is the difference between N bit and m bit numbers?

N bit and m bit numbers refer to the number of bits, or binary digits, used to represent a number. The main difference between them is the number of bits they use, with N bit numbers using N bits and m bit numbers using m bits. This affects the range of numbers that can be represented, with N bit numbers being able to represent a larger range of numbers compared to m bit numbers.

How do N bit and m bit numbers affect computer processing?

The use of N bit and m bit numbers can affect computer processing in terms of speed and memory usage. N bit numbers require more processing power and memory compared to m bit numbers due to their larger range of numbers. This can impact the efficiency and speed of calculations and operations performed by a computer.

What is the purpose of using N bit and m bit numbers?

N bit and m bit numbers are used to represent and store numerical data in a binary format. This allows computers to perform mathematical operations and calculations efficiently, as they are designed to work with binary data. N bit and m bit numbers also allow for a larger range of numbers to be represented, making them useful in various applications and industries.

How are N bit and m bit numbers used in encryption?

N bit and m bit numbers are used in encryption algorithms to generate keys. These keys are used to encrypt and decrypt data, making it more secure. N bit and m bit numbers are also used in cryptographic functions to perform calculations and operations, making them a crucial component in ensuring the security of data.

Can N bit and m bit numbers be converted into each other?

Yes, it is possible to convert between N bit and m bit numbers. This can be done by adding or removing bits from the number, resulting in a different range of numbers being represented. However, this conversion may result in loss of precision or accuracy, depending on the size and type of numbers being converted.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
32
Views
1K
  • Programming and Computer Science
Replies
1
Views
928
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
2
Views
2K
Replies
3
Views
228
  • Precalculus Mathematics Homework Help
Replies
12
Views
954
Back
Top