How to calculate size of memory by given a range of address?
the equation is
second_add - first_add + 1
example
fdff ffff - fd00 0000 + 1 = 0100 0000 = 2^24 = 2^4 * 2^20 = 16Mbyte [2^20 byte = 1 Mbyte]
Sorry, to answer a question with another question/s...
Isn't the number of addresses available within a stated range inclusive of those range limiters aswell? e.g. (in decimal to illustrate my point) with a start address 5, and an end address of 10. With subtraction only i.e. end address minus start address (10-5) we get a range of 5. But there are actually six unique addresses in the range i.e. 5,6,7,8,9,10 (so we should add 1 to the result of the subtraction in Julie's original question?)
Also, memory address size versus actual memory size. Are we talking about the number of individual memory locations or the size of the memory available to store data in (which should take into account the size of each location)?
If its just memory locations, then we are almost done (I think this is referred to as memory address size). Just have to work out the MB part of the question (I'll come to that issue at the end)
If its the available storage space, this should include the size of each addressable portion of memory e.g. each address location holds an unknown sized chunk of data. Say if it is 1 byte (1B) of data per memory location than my example above means the memory size is: 6 (memory locations) multiplied by 1 Byte (volume of each memory location)for a total memory size of 6B
So based on my logic, the answer to original question for Range 1 should be 01000000hex (range1 = FDFF FFFF-FD00 0000 + 1 = 01000000h).
As for the memory size of that range, this is where I get really confused.... It is a specific number of memory locations i.e. 1000000h, of some undetermined size for each location. So why express it in MB or GB. If you do know the size of each memory location (and multiply number of locations by by the size of each location, then you have the memory size for that range and can express it in numerical form.
And while we are at it, where I get really really confused is the use of MB, GB etc. It is often cited as each prefix equates to a multiple of 1024 e.g. 1KB = 1024Bytes, 1MB = 1024kB etc but the IEC preferred convention is based on the ISO standard (according to my googling just now) which says Kilo (kB) = 1000, Mega (MB) = 1000000 etc.
So putting the unknown size of each location aside, and converting 1000000h to decimal i.e. 16,777,216 the answer is either:
- 16MB (16777216/1024/1024=16) I SUSPECT THIS IS THE ANSWER THE TEACHER IS AFTER
- 16.777216MB (according to the ISO standards)
- 16 mebibytes (according to the joint IEC/ISO standard - IEC 80000-13)
Btw, Googling only just educated me (may be taken to mean recently and partially) on kibibytes and mebibytes...if you're interested, check out https://en.wikipedia.org/wiki/Kilobyte
In your example for Range 1, you are correct. That is the size of the memory, stated in hexidecimal, in bytes.
You may gain the most insight by first converting 00FF FFFF to a decimal number, then converting that number of bytes into megabytes.
To convert from bytes to megabytes use the relationship
1 MB = 1 Megabyte = 1024 * 1 KB = 1,048,576 bytes.
There are tons of online Hex to Decimal converters. The calculator built in to Windows can also do the conversion.
For the other ranges, you again want to do subtraction to determine the size of the range, and then apply the steps above, e.g.
FBFF FFFF
-
FA00 0000
---------
01FF FFFF
Having gone through those steps to better grasp what is happening, the following relationship will allow you to answer such questions faster:
0010 0000 = 1,048,576
So 1MB is the same as 0010 0000 (sometimes called 0x100000).