Binary and Decimal prefixes

This article explains what decimal and binary prefixes are, when they should be used, what are the differences between them and how they are used with hardware and software.

Table of Contents

Decimal Prefixes - The SI standard

The International System of Units (abbreviated SI) defines a set of prefixes, with an associated symbol, to represent multiples (or submultiples) of a unit of measure. For example, the kilo- prefix can be combined with the unit metre to form "kilometre". Kilo- means ×1000 or ×10³ and its symbol is "k" (lower-case letter 'k'), thus a km is equal to 1000 metres (or 1 m × 10³).

Every decimal prefix denotes a specific power of 10 and has a name and a symbol, as shown in the following table:

The SI prefixes*
* Only the prefixes that denote positive powers of 10 are listed in this table.
** Note that only the "kilo-" prefix has a lowercase symbol ('k').
Prefix Symbol Value Decimal Equivalent
kilo- k** 1000^1 = 10^3 1 000
mega- M 1000^2 = 10^6 1 000 000
giga- G 1000^3 = 10^9 1 000 000 000
tera- T 1000^4 = 10^12 1 000 000 000 000
peta- P 1000^5 = 10^15 1 000 000 000 000 000
exa- E 1000^6 = 10^18 1 000 000 000 000 000 000
zetta- Z 1000^7 = 10^21 1 000 000 000 000 000 000 000
yotta- Y 1000^8 = 10^24 1 000 000 000 000 000 000 000 000

To denote the submultiples of the units of measure, there are also other SI prefixes with a negative power of 10, such as milli-, micro-, nano-, etc. (for instance, a nanometer is equal to 0.000000001 metres or 1 m × 10⁻⁹ and its symbol is "nm") but since they are not often used in computing we won't discuss about them.

The "k" case

All the prefixes shown in the previous table are written in the upper-case form except the "k". In SI the "K" symbol represent the kelvin, a unit of temperature. Even though it's unlikely that the "K" used as kelvin and the "K" improperly used as kilo- might be confused, the latter is wrong. Sometimes "K" is used to indicate ×1024 (2¹⁰) and "k" ×1000 (10³) but this hasn't been standardized and also it can't be extended to the other units, thus the "K" should never be used as a prefix.

In computing, the units bit and byte are often expressed using powers of 2 and the small difference between 1024 (2¹⁰) and 1000 (10³) led the IT specialists to adopt the use of kilo- to mean 1024. About 40 years ago, when they started to use this notation, they all knew that the term kilobyte was intended as 1024 bytes and there was no confusion, but when laymen and other specialists (such as scientists and engineers) started to use computers, they weren't aware of this difference.

Moreover, these decimal prefixes are sometimes used with their original meaning even in computing. There was the need of a different set of binary prefixes to resolve this ambiguity.

Binary Prefixes - The IEEE 1541 standard

On page 23 of the 7th edition of the SI brochure, published in 1998, there is a marginal note that, referring to the decimal prefixes, says:

These SI prefixes [the decimal prefixes] refer strictly to powers of 10. They should not be used to indicate powers of 2 (for example, one kilobit represents 1000 bits and not 1024 bits).

On December 1998, IEC defined a set of binary prefixes to denote powers of 2 in a document named International Standard IEC 60027‐2: Letter symbols to be used in electrical technology (specifically in Part 2: Telecommunications and electronics). Four years later, the IEEE-SA adopted these prefixes in the standard no. 1541-2002 for a trial period of 2 years and, on March 2005, it has been elevated to a full-use standard.

In the following table are listed all the binary prefixes defined in these standards:

IEC/IEEE binary prefixes
* The prefixes zebi- and yobi- were added on August 2005, in the third edition of IEC 60027-2
Prefix Symbol Value Decimal Equivalent
kibi-Ki1024^1 = 2^101 024
mebi-Mi1024^2 = 2^201 048 576
gibi-Gi1024^3 = 2^301 073 741 824
tebi-Ti1024^4 = 2^401 099 511 627 776
pebi-Pi1024^5 = 2^501 125 899 906 842 624
exbi-Ei1024^6 = 2^601 152 921 504 606 846 976
zebi- *Zi1024^7 = 2^701 180 591 620 717 411 303 424
yobi- *Yi1024^8 = 2^801 208 925 819 614 629 174 706 176

The names of the new prefixes are formed adding the letters "bi" (for binary) after the first two letters of the corresponding SI prefix (e.g. giga + bi = gibi). Their symbols are formed adding a "i" to the SI symbol (e.g. G + i = Gi). Note that, for consistency with the others, the simbol for kibi- is "Ki" and not "ki".

With these prefixes is thus possible to indicate binary multipliers and preserve the decimal meaning of the SI prefixes, avoiding ambiguity.

Using decimal and binary prefixes

A common mistake is to think that the correct thing to do now that the binary prefixes have their own symbols, is to just use them everywhere. Even thought using the right binary prefix is certantly better than misusing the decimal ones, there's no real reasons to use binary prefixes in most of the cases.

Using binary prefixes makes sense only when the quantity we are dealing with is a power of 2.

Working with powers of 10 is easier, therefore, if the quantities we are dealing are not exact powers of 2, decimal powers should be preferred.

Let's see a few examples of quantities that should be indicated using decimal and binary prefixes:

Decimal prefixes
File size (bytes)
Disks and drives size (bytes)
Transfer speed (bits/second)
Processor speed (hertz)
Binary prefixes
RAM (bytes)
CPU cache (bytes)

File sizes are probably the quantities that are most frequently found while working with PCs. File sizes are not powers of 2. For example, this document is now 29131 bytes, and it's easier to express this as 29.1 kB rather than 28.4 KiB.

Decimal and binary arithmetic

With decimal prefixes it's also a lot easier to add and subtract values with different prefixes. For example assume that we have a 4.7 GB DVD and we want to burn some files on it:

  1. a 4.35 GB video;
  2. a 342 MB zip archive;
  3. ten 750 kB photos;

The sizes are expressed with decimal prefixes so it's easy to convert them to MB:
4.35 GB = 4.35 × (1000 MB) = 4350 MB;
10 × 750 kB = 7500 kB = 7500 × (0.001 MB) = 7.5 MB;
(a GB is equal to 1000 MB and a kB is equal to 0.001 MB)

and add them together:
4350 MB + 342 MB + 7.5 MB = 4699.5 MB

Since 4699.5 MB is smaller than the size of the DVD (4700 MB) we will be able to burn all the files.

Let's do the same calculation again, but assuming that the sizes of the files are instead expressed with binary prefixes.

  1. a 4.35 GiB video;
  2. a 342 MiB zip archive;
  3. ten 750 KiB photo;

The sizes are expressed with binary prefixes so it's more difficult to convert them to MiB:
4.35 GiB = 4.35 × (1024 MiB) = 4454.4 MiB;
10 × 750 KiB = 7500 KiB = 7500 × (~0.001 MiB) = 7.324 MiB;
(a GiB is equal to 1024 MiB and a KiB is equal to ~0.000976 MiB)

and add them together:
4454.4 MiB + 342 MiB + 7.324 MiB = 4803.724 MiB

Our DVD uses decimal prefixes and its size is 4.7 GB, so we need to convert 4803.724 MiB to decimal prefixes to see if there's enough room for all the files:

first we can try to convert to GiB:
4803.724 MiB = 4803.724 × (~0.001 GiB) = 4.691 GiB

it seems that the files will fit, but to be sure we need to convert it to GB:
4.691 GiB = 4.691 × 2^30 / 10^9 bytes = 5.037 GB

After several conversion we finally found out that the exact size of all the files is 5.037 GB and therefore there's not enough space on DVD to burn them all.

Even though it's now clear how using decimal prefixes greatly simplifies calculations, several applications still prefers to use binary prefixes. The main reason is that decimal prefixes were (and are) often misused (e.g. by Windows), so it's not clear if 1 MB is used correctly with the meaning of 1 000 000 bytes or if it's misused to represent 1 048 576 bytes. Using MiB avoids ambiguity and clarifies that the quantity is equal to 1 048 576 bytes, but on the other hand it makes the calculations more difficult.

A better approach would be to use decimal prefixes (with their correct meaning of course), and possibly specify the exact size in bytes or add a note to clarify that the application is using decimal prefixes.

Differences between Decimal and Binary Prefixes

As noted by the IT specialist, the difference between 1 kB (1000 bytes) and 1 KiB (1024 bytes) is not so much, but it grows with the larger prefixes.

This table and graph show the differences between decimal and binary prefixes. For example, 1 GB is equal to 0.93 GiB, with a difference of -6.9%.

kB:KiBMB:MiBGB:GiBTB:TiB PB:PiBEB:EiBZB:ZiBYB:YiB
Decimal 1.00 kB1.00 MB1.00 GB1.00 TB 1.00 PB1.00 EB1.00 ZB1.00 YB
Binary 0.98 KiB0.95 MiB0.93 GiB0.91 TiB 0.89 PiB0.87 EiB0.85 ZiB0.83 YiB
Difference -2.3%-4.6%-6.9%-9.1% -11.2%-13.3%-15.3%-17.3%
Differences between decimal and binary prefixes

Graph 1 - Differences between decimal and binary prefixes

The following table and graph, instead, show the differences between binary and decimal prefixes. For example, 1 GiB is equal to 1.07 GB, with a difference of +7.4%.

KiB:kBMiB:MBGiB:GBTiB:TB PiB:PBEiB:EBZiB:ZBYiB:YB
Binary 1.00 KiB1.00 MiB1.00 GiB1.00 TiB 1.00 PiB1.00 EiB1.00 ZiB1.00 YiB
Decimal 1.02 kB1.05 MB1.07 GB1.10 TB 1.13 PB1.15 EB1.18 ZB1.21 YB
Difference +2.4%+4.9%+7.4%+10% +12.6%+15.3%+18.1%+20.9%
Differences between binary and decimal prefixes

Graph 1 - Differences between binary and decimal prefixes

Finally, this table combines the two previous tables and summarizes the differences between the prefixes, showing their exact value in bytes.

PrefixValue% Difference PrefixValue% Difference
kilo-1000-2.3% peta-1000000000000000-11.2%
kibi-1024+2.4% pebi-1125899906842624+12.6%
mega-1000000-4.6% exa-1000000000000000000-13.3%
mebi-1048576+4.9% exbi-1152921504606846976+15.3%
giga-1000000000-6.9% zetta-1000000000000000000000-15.3%
gibi-1073741824+7.4% zebi-1180591620717411303424+18.1%
tera-1000000000000-9.1% yotta-1000000000000000000000000-17.3%
tebi-1099511627776+10% yobi-1208925819614629174706176+20.9%

As we said at the beginning of this paragraph, the difference between 1 kB and 1 KiB is only 24 bytes, but between 1 TB and 1 TiB is about 99.5 billions bytes, that is ~100 GB. Between a YB and a YiB is even greater: about 209 thousand billion billions bytes (i.e. ~209 EB or ~209 billion GB).

It's quite clear that the difference will keep increasing as long as the technology will evolve, and that small errors will become huge. Nowadays we already use gigabytes and terabytes and these differences are already noticeable.

Prefixes use with hardware

We will now analize how these prefixes are used to specify the size of mass-storage devices, memories and the speed of processors.

Hard disks drives

The size of the hard disks is probably one of the well-known cases where the differences between the prefixes leads to confusion. Due to the high number of bytes that a modern hard disk can store, it's easy to see the divergence between what you read on the package and what your operative system may see.

If you buy a 500 GB hard disk you will probably note that some operative systems (e.g. Microsoft Windows) only see ~465 "GB", and you may wonder why 35 GB have disappeared. Actually those 35 GB are not disappeared, the size of the hard disk is really 500 GB and the OS can see all the bytes, but since it misuses the decimal "GB" with binary meaning (instead of using "GiB") the two values appear to be different.

The hard disks manufacturers usually use the SI decimal prefixes and thus they correctly state the capacity of the disks in giga or tera bytes. On the other hand, Windows uses "MB" and "GB" to indicate mebibytes (MiB) and gibibytes (GiB) instead of megabytes and gigabytes.

Math may help us to understand better:

1 GB is equal to 10^9 bytes, thus:
500 GB = 500 × 10^9 B =
500 × 1 000 000 000 bytes =
500 000 000 000 bytes
;

1 GiB is equal to 2^30 bytes.
We want to know how many GiB are 500 000 000 000 bytes, so:
500 000 000 000 bytes / 2^30 =
500 000 000 000 bytes / 1 073 741 824 =
465.66 GiB
.

Therefore 500 GB = 465.66 GiB.

Floppy disks

Nowadays the 3½ inch diskettes are no longer used and their size is small enough to overlook the error, but there is an interesting anectode about them. Their size is supposed to be 1.44 "MB", but this unit does not refer to megabytes nor to mebibytes; it is instead an "hybrid" between the two. This "third MB" is equal to 1 024 000 bytes (1000 × 1024 B), while a megabyte is equal to 1 000 000 bytes (1000 × 1000 B) and a mebibyte is equal to 1 048 576 bytes (1024 × 1024 B).

We could indeed name this "hybrid" unit "kilo-kibibyte", that is 1000 (kilo-) × 1024 (kibi-) bytes, and we also correctly say that the size of a floppy is 1 440 KiB.

A floppy can store 512 bytes per sector and it has 2 sides divided in 80 tracks where each track has 18 sectors. Once again math can help us:

The size of a floppy, in bytes, is:
512 bytes × 18 (sectors) × 80 (tracks) × 2 (sides) = 1 474 560 bytes

If we divide this value with the value of the "third MB" we obtain:
1 474 560 bytes / 1 024 000 = 1.44 "third MB"

Actually, its real size in MB and MiB is:
1 474 560 bytes / 1 000 000 = 1.474 MB, or
1 474 560 bytes / 1 048 576 = 1.406 MiB.

We also said that its size is 1 440 KiB:
1 440 KiB = 1 440 × 1024 B = 1 474 560 bytes

Once again the real size of the floppy is not the one that the OS may see. In this case is not only due to the use of the prefixes. For example, Windows detected only 1.38 MiB (even if it calls them MB) instead of 1.40 because some of the sectors are used by the file allocation table (FAT) and the boot sector or they are reserved. This happen with other storage devices too, but the number of non-detected bytes compared with the overall size of the devices is usually fairly small.

Flash Drives

The size of flash drives (e.g. USB Flash Drives and Memory Cards) is usually measured in powers of two (..., 128, 256, 512 MB; 1, 2, 4, 8, 16 GB, ...) and this may lead to think that their value is expressed using binary prefixes, but this is not true. Althought these values are powers of two, the prefixes they use are decimal, so a 512 MB and a 4 GB USB flash drive can store respectively roughly 512 000 000 and 4 000 000 000 bytes.

RAM

Unlike flash drives, Random Access Memory (RAM) uses binary prefixes. Since the CPU registers responsible for addressing memory follow a binary logic, they can address a number of bytes in the RAM equal to a power of two. For instance, a 32-bit processor can directly address 4 294 967 296 bytes (exactly 4 GiB or 2³² bytes). The aforementioned is also applicable to the memory of video cards and other similar types of memory.

CPU

The frequency of a CPU is usually measured in GHz where "G" is the symbol for the SI decimal prefix giga- and "Hz" the SI unit that represent the hertz, a unit of frequency. Since there is no reason to use binary prefixes in this situation, only the decimal prefixes are used. For example, a CPU with a frequence of 2 GHz will be able to do 2 000 000 000 cycles in a second (one hertz is equal to one cycle per second). On the other hand, all the size of registers as well as the cache memory are based on powers on two, so they use binary prefixes.

Prefixes use with software

Different operative systems and applications use different conventions while using prefixes.

Microsoft Windows

Windows uses decimal prefixes (MB, GB, ...) with binary meaning (MiB, GiB, ...) and it uses KB with the upper-case "K". It doesn't seem aware of the existence of binary prefixes, even though some third-party applications (e.g. FileZilla) might use them. It also seems that the size shown by Windows is truncated instead of rounded (e.g. 123.97 GB are displayed as 123 GB) and this introduces further errors.

There are errors even in the documentation, for instance, in the article Determining Actual [Floppy] Disk Size there's written: Although its size has been popularly called 1.44 MB, the correct size is actually 1.40 MB. and There are 1024 bytes in a kilobyte, not 1000.. We have seen that the size of a floppy is 1.40 MiB, not 1.40 MB and that in a kilobyte there are 1000 bytes, not 1024 — exactly the opposite of what the article says.

Linux

The kernel use the prefixes correctly but other applications might follow different conventions. For instance, dd can understand both the decimal and the binary prefixes:

$ dd if=/dev/zero of=test bs=1MB count=20
20+0 records in
20+0 records out
20000000 bytes (20 MB) copied, 0.075621 seconds, 264 MB/s
$ dd if=/dev/zero of=test bs=1MiB count=20
20+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 0.0858899 seconds, 244 MB/s

(With the first command, dd copies, from /dev/zero to a file named test, 20 blocks with the size of 1 MB, that is 20 MB. In the output we can see that it has copied exactly 20 000 000 bytes. Instead, if we change the block size from 1 MB to 1 MiB it will copy 20 971 520 bytes, that is 20 MiB or 20.97 MB — rounded to 21 MB in the output.)

On recent versions of Linux, applications and file managers like Dolphin or Konqueror use binary prefixes (KiB, MiB, GiB, ...).

Conclusions

We can finally summarize what we saw in the article and give some suggestions and guidelines:

Ezio Melotti - ©2008-2010 - This work is licensed under a Creative Commons BY-NC-SA 3.0 License.