3 ms·
The explanation that "base 2 is natural for memory" makes absolutely no sense. Base 2 prefixes make sense for memory because memory chips have a power-of-two c
by revelation 11y ago
The explanation that "base 2 is natural for memory" makes absolutely no sense.
Base 2 prefixes make sense for memory because memory chips have a power-of-two capacity. Base 2 prefixes makes sense for address space because n bits can identify 2^n different addresses. Page sizes are base 2 because it allows for easy bit masking to select the page number and the address within the page. Bit masking is, in fact, one of the main advantages of base 2. So yeah, base 2 has its place.
We can make hard drives that have a base 2 capacity. We can make flash drives with that capacity. The reality is that we can pretty much make them any capacity we want. The fact that it's convenient to calculate with base 2 capacities on a machine where it is most convenient to calculate with base 2 numbers comes as no surprise and is equally valid to any form of memory or storage medium.
That doesn't make memory "naturally base 2", of course. memcpy doesn't stop working when I specify a size that isn't a multiple of sizeof(int). We could work with non-base 2 memory capacity perfectly well while losing none of the performance.
So the author here ends up trying to make post hoc rationalizations for why some things ended up base 2 and other base 10 when really for any amounts the benefits he ascribes to base 2 memory apply.
- brucedawson 11y agoYou're reading more into that sentence than I intended. I meant that base 2 is natural for memory capacity because that is how chips are made, so it makes things work more neatly. It lets us say "8 GB of RAM" instead of "8.59 GB". All RAM chips have a power-of-two capacity and while that might be multiplied by a small non-power-of-two (sometimes three) when multiple chips are put in a system, powers-of-two make talking about memory easier. Ditto for 4-K pages, 2-MB pages, 64-KB caches, etc. When allocating buffers and using memcpy there is (modulo cache effects) no reason to prefer base 2. char buf[1000] works about as well as char buf[1024]. > We can make hard drives that have a base 2 capacity. Sure, but it's a needless constraint. Whereas I'm not aware of anybody ever making a RAM chip that isn't a base 2 capacity.
- tremon 11y agobase 2 is natural for memory capacity because that is how chips are made I think this is a fundamental misconception. How they're made is irrelevant except for why they're made that way. And that's because of memory addressing: a memory address is signaled by using a number of parallel bit lanes. The power of 2 comes from the fact that every lane has two states. The same goes for aggregating multiple addresses (like page size and cache size): the most efficient (and therefore only viable) way to aggregate blocks of contiguous memory is to mask out the least significant bits of the address, which is why you also get base-2 multiples for memory aggregation. Therefore, the fundamental expression of memory capacity is the number of usable address lines multiplied by the minimum addressable unit (byte for RAM, 512 bytes for old hdd's, 2048 bytes for cdrom, 4096 bytes for new-format disks). As for hard disks, they use the same method of adressing as memory does! In fact, the fundamental addressable unit already is a multiple of 2, not 10, as I mentioned above. The main difference between volatile and non-volatile memory is that the number of address lines is set by standard (it's still 48 I believe) so the available capacity must be probed by some other way. And as hard disks are slow anyway, manufacturers can get away with adding a new layer of indirection (firmware) on their disks which hides the address implementation. But in my view, there is no valid technical reason for storage sizes to be expressed in multiples of 10.
- brucedawson 11y agoA memory chip has a capacity that is an exact power of two. Hard drives - not so much. Check out this reference: http://www.pcguide.com/ref/hdd/geom/geomLogical-c.html http://www.pcguide.com/ref/hdd/geom/geomLogical-c.html The drive they discuss has 6 read/write heads, 6,810 cylinders, and 122 to 232 sectors per track (presumably more on the outer tracks). None of these numbers are the slightest bit base-2-ish, which is why capacities are rarely near powers of 2. So, there is no valid technical reason for storage sizes to be expressed in powers of 2.
- ambrop7 11y ago(this is speculation only but I suspect it's right) When the individual memory chips on a RAM stick have base-2 capacity, it is easy to make a request get serviced by the right chip. You just take some higher bits of the address as the chip ID and the lower bits as the offset within that chip. With non base-2 chips, you'd have to do many comparisons and a subtraction, or deal with discontinuous memory. It probably also helps with the internal design of the memory chips for similar reasons. I'm guessing the same reasoning doesn't apply to hard drives because of much different performance and technology (disks have possibly multiple microcontrollers inside which don't have much problem with a bit of integer arithmetic).
- marcosdumay 11y agoHum, nope. Solid state memory is inherently built in powers of 2. Since addressing is a big part of the chip, and addressing is inherently at powers of 2, making them in any other way would be wasteful. Hard disks aren't inherently divided in cylinders, sectors and plates. Those come in several different distribution, without the power of 2 bias. Flash memory comes in powers of 2, but flash drivers reserve some of it, thus flash drivers are inherently a little bit smaller than a power of 2.