~/jackwent.co.uk
jack@jackwent:~$ ./memory-calc

Memory Calculator

How many MB is 8 GB of RAM? It depends who’s counting. Computers count in 1024s, so 8 GB is 8,192 MB. Drive makers count in 1000s, so they’d call it 8,000 MB. This calculator shows both side by side.

It’s handy when a hypervisor wants the VM’s memory in MB, when a script wants a size in bytes, or when you’re wondering where part of your new hard drive went.

jack@jackwent: ~/tools/memory-calcbytes

UnitBinary (1024)Decimal (1000)

Why is my drive smaller than it says on the box?

Binary vs decimal

There are two ways of counting storage, and both use the same names, which is where all the confusion comes from.

UnitBinary (RAM, Windows)Decimal (drive makers, network speeds)
1 KB1,024 bytes1,000 bytes
1 MB1,024 KB = 1,048,576 bytes1,000 KB = 1,000,000 bytes
1 GB1,024 MB = 1,073,741,824 bytes1,000 MB = 1,000,000,000 bytes
1 TB1,024 GB1,000 GB
1 PB1,024 TB1,000 TB

The gap grows with every step up. A KB is only 2.4% out, but a TB is nearly 10% out.

To clear this up, the binary units were given their own names: KiB, MiB, GiB and TiB (kibibyte, mebibyte and so on). Linux tools like free -h and df -h and most hypervisors use them. Windows still uses the binary values but calls them KB, MB and GB, which is why the two never seem to agree.

Common RAM sizes in MB

Hyper-V, Proxmox, VMware and most VM settings want memory in MB. These are the numbers to type in:

RAMIn MBIn bytes
512 MB512536,870,912
1 GB1,0241,073,741,824
2 GB2,0482,147,483,648
4 GB4,0964,294,967,296
6 GB6,1446,442,450,944
8 GB8,1928,589,934,592
12 GB12,28812,884,901,888
16 GB16,38417,179,869,184
24 GB24,57625,769,803,776
32 GB32,76834,359,738,368
64 GB65,53668,719,476,736
128 GB131,072137,438,953,472

Where did my disk space go?

Buy a 1 TB drive, plug it in, and Windows says 931 GB. Nothing is missing. The maker counted 1,000,000,000,000 bytes in 1000s, and Windows counted the same bytes in 1024s:

On the boxWhat Windows shows
256 GB238 GB
500 GB465 GB
1 TB931 GB
2 TB1.81 TB
4 TB3.63 TB
8 TB7.27 TB

The real space is then a little lower still, because the file system and the recovery partition take their share.

Bits vs bytes

Network speeds are in bits, files are in bytes, and there are 8 bits in a byte. So a 100 Mbps broadband line downloads at about 12.5 MB per second at best. If your download seems eight times slower than it should be, that’s why.

If you’re planning networks rather than storage, the subnet calculator works out IP ranges, and the commands page has free -m and df -h for checking what a machine actually has.

[jackwent]