Why are RAM size usually in powers of 2 (512 MB, 1, 2, 4, 8 GB)?

The newer computers usually have 2, 4, 8, etc GB of memory. The older ones usually have like 128, 256, 512 MB or less but usually also in powers of two.

What is the reason behid this? Why don't hard disks and DVDs follow this norm?

-

Memory is closely tied to the CPU, so making their size a power of two means that multiple modules can be packed requiring a minimum of logic in order to switch between them; only a few bits from the end need to be checked (since the binary representation of the size is `1000`...`0000` regardless of its size) instead of many more bits were it not a power of two.

Hard drives are not tied to the CPU and not packed in the same manner, so exactness of their size is not required.

-

Simply speaking, computers work in 1s and 0s. That's what binary is. The computer uses this system to address memory. In a simple (read "ancient") system, a certain number of processor lines or memory address unit lines are dedicated to selecting the address of a particular location in memory. Since those lines can only carry values of "high" or "low" each line represents a binary digit. So the number of locations that can be addressed is two to the power of the number of lines.

There is a correspondence between this and the address registers in the processor. Two to the number of bits in the register is the number of locations that can be addressed.

As memory sizes increased and computers became more powerful, a number of schemes have been employed to extend this capability and work around various limitations.

Please note that this overview is a greatly simplified look at a complex subject.

Also see the Wikipedia article on Memory addressing.

-

The binary system is known as base 2 because there are two possible values: 0 and 1 (on and off, high and low, 5V and 0V), compared to the normal natural number system known as base 10 (0-9). Hard drive manufacturers want their capacity to appear higher, so a 1GB drive (base 10, 1 billion bytes, 109) is really only 0.9313GiB (base 2, 2something) (this is also the reason for the disparity between what the computer reports and what the box says). The same is true for DVD discs.

-
Check out this Wikipedia article for more info - en.wikipedia.org/wiki/Power_of_two –  Nick Josevski Jan 19 '11 at 3:46
@muntoo: You have linked to relevant info but your comment text is totally misleading and makes you look spammy. –  Linker3000 Jan 19 '11 at 8:29
I edited @Muntoo's comment –  Ivo Flipse Jan 19 '11 at 16:20

Bulk production is usually cheaper then diverse production. Producing 128MB and 256MB prints can be more expensive then just producint 256MB prints.

So if not a whole lot of different ram is produced you can best 'double' them to achieve the cheapest result.

Installing two of the same ram strips has the advantage that they should work together. Mixing different brands can result in some small differences slowing your machine down.

Dual channel ram works really great together if you add two strips off ram that are the same.

Ram is produced using smaller 'sub' chips. These chips are usually locked into a usable size. OS'es from a histroically prospective like simple 1024Kb blocks to use. So you wan't a multiple from that installed.

-

Memory and processors have to use exact math, hard drives and cd roms don't need to, well not exactly, the OS takes care of that when it formats the hard drive or burns the CD.

Nice explanation of computer math here

http://www.wimp.com/egyptiansmath/

So some computer parts marketing is exact, and some is not exact.

-