-1
\$\begingroup\$

A memory component spans the address range 0x00400000 to 0x007FFFFF, what is its capacity?

I only know the calculate the two address difference, i.e 3FFFFF,the correspond decimal is 4194303,convert this can get answer 4MB, but the standard answer like this: enter image description here

How to understand standard answer?

\$\endgroup\$

closed as unclear what you're asking by Dmitry Grigoryev, StainlessSteelRat, Edgar Brown, Sparky256, Finbarr Mar 4 at 17:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ In a street there's an apartment building, each apartment has it's own number. On the building there is a sign: apartments 101 - 250. How many apartments are there in the building? I think it is 149. How did I calculate that? Now replace apartment numbers with memory locations. How many memory locations are there? \$\endgroup\$ – Bimpelrekkie Feb 28 at 13:15
  • 2
    \$\begingroup\$ @Bimpelrekkie: Why aren't there 150 apartments? If you subtract 100 from the apartment number, you can count them, 1 to 150. Similarly, if you subtract 0x3FFFFF from the memory addresses, you can count those, too, 1 to 0x400000. If an address represents one byte (not specified in the question), that's 4 MB. But the question is about explaining the "standard answer" method, not getting the right answer. \$\endgroup\$ – Dave Tweed Feb 28 at 13:32
  • 1
    \$\begingroup\$ @DaveTweed You're correct, the right answer is 150. I'll excuse myself by saying it was a deliberate mistake to trigger the sharp reader ;-) I personally do not see much difference between the two methods except that in the "standard method" the numbers are expressed as powers of 2. \$\endgroup\$ – Bimpelrekkie Feb 28 at 13:35
  • 1
    \$\begingroup\$ Using pictograms for your username makes it difficult for many of us to direct comments to you. I can usually type a @ followed by the first few characters of a name, but I can't type the characters you use. It's your choice, of course, but I just wanted to understand how things work. \$\endgroup\$ – Elliot Alderson Feb 28 at 14:11
  • \$\begingroup\$ You are doing subtraction, which is an efficient and universal solution. In contrast, the proposal given to you attempts to explain subtraction, but in a way restricted to aligned powers of two... Apart from neglecting to count both the first and last storage location, you are ahead of what was proposed to you. But sometimes in an educational context you can be asked to "do it their way" even when "their way" is inefficient and perhaps even confusing. \$\endgroup\$ – Chris Stratton Feb 28 at 17:06
3
\$\begingroup\$

The "standard answer" is based on observing that there are 22 bits that can vary when addressing this memory — the other 10 bits are constant, regardless of the address.

22 bits can represent 222 different values (addresses), so the memory has 4194304 unique addresses. If each address represents a byte (something not specified in the actual question!) then it has a capacity of 4 MB.

It would be more correct to say that it has 4 M words, leaving the word size unspecified.

\$\endgroup\$
  • \$\begingroup\$ Thank you, but the actual correspond decimal is 4194303? It is almost closed to 4MB, i.e 4095.99902344KB, so the answer can be 3.99MB or not? \$\endgroup\$ – 余星佑 Feb 28 at 13:53
  • \$\begingroup\$ No, it's exactly 4194304 different addresses, ranging from 0 to 4194303. \$\endgroup\$ – Dave Tweed Feb 28 at 14:01
  • \$\begingroup\$ So like this kinds of question the memory location always the tail - head + 1? \$\endgroup\$ – 余星佑 Feb 28 at 14:06
  • \$\begingroup\$ @TheOP International standards say that \$10^6\$ bytes equals one megabyte (MB) but \$2^{20}\$ bytes equals one mebibyte (MiB). Perhaps that is the source of your confustion. However, some people still use megabyte when they really mean mebibyte. \$\endgroup\$ – Elliot Alderson Feb 28 at 14:07
  • 1
    \$\begingroup\$ @ElliotAlderson: Actually, that would be MOST people, other than disk drive manufacturers and hopeless pedantics. \$\endgroup\$ – Dave Tweed Feb 28 at 14:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.