For novel ideas about building embedded systems (both hardware and firmware), join the 27,000+ engineers who subscribe to The Embedded Muse, a free biweekly newsletter. The Muse has no hype and no vendor PR. It takes just a few seconds (just enter your email, which is shared with absolutely no one) to subscribe.

By Jack Ganssle
kibi
Published 10/03/2002
K: (n., adj.) a binary thousand, which isn't a decimal thousand or even really a binary thousand (which is 01000b, or eight), but is the binary number closest to a decimal thousand. This has proven so completely confusing that is has become a standard.
Or has it?
What does "kilo" really mean? Is it 1000 or 1024? How about "mega"? The International Systems of Units has precise definitions for these terms, though few computer people abide by their rules. Kilo denotes 1000 decimal, abbreviated "k" (lower case). Mega corresponds to 1 000 000 (abbreviated "M"  upper case) and giga ("G") is 1 000 000 000.
Now that we understand that, is 16 kb of RAM 16 000 bytes? 16 384 bytes? 16 384 bits? Perhaps the difference between 16 000 and 16 384 isn't much, but the distinction between bytes and bits seems fundamental to me. Most of us assume the context of a discussion will illuminate our meaning. Thus, a 256 Mb RAM chip is a quarter giga bits, yet 256 Mb of RAM in the PC is that many bytes.
How important is the case of the "mega" or "kilo"? Lower case "m" means "milli", so specifying 4 mb of RAM means we want .004 bytes.
Seems to me that engineering requires precision, yet our basic unit of measurement is poorly understood and erratically applied. Turns out those fun folks at the International Electrotechnical Commission have defined units for binary prefixes. The system is:
2**10 is one kibi, abbreviated Ki. One kibi is 1024.
2**20 is one mebi, abbreviated Mi. One mebi is 1 048 576.
2**30 is one gibi, abbreviated Gi. One gibi is 1 073 741 824.
These prefixes are contractions of "kilobinary" (kibi), "megabinary" (mebi) and "gigabinary" (gibi).
A byte is abbreviated "B" (capital B, that is), and a bit is, well, "bit". Don't use the lowercase "b" as it has no meaning.
Thus:
1 kibibyte is 1 KiB, or 1024 bytes
1 kibibit is 1 Kibit, or 1024 bits
1 mebibyte is 1 MiB, or 1 048 576 bytes
1 mebibit is 1 Mibit, or 1 048 576 bits
1 gibibyte is 1 GiB, or 1 073 741 824 bytes
1 gibibit is 1 Gibit, or 1 073 741 824 bits
The IEC's definitions include binary prefixes for numbers up to 2**60 (exbi, or "Ei"). See http://physics.nist.gov/cuu/Units/binary.html for more prefixes.
Confusing? You bet. But maybe such standards are needed. Notice I avoided the use of the word "billion"; to Americans it means 10**9, but to engineers in the UK a billion is a million million, or 10**12. See http://www.unc.edu/~rowlett/units/large.html. That's not a trillion, since in the UK a trillion is 10**18. I bet the USA's 6 trillion dollar debt really makes eyes pop in England.
Churchill said "We are two peoples divided by a common language". The point of standards is to join rather than separate, to enhance communication rather than obfuscate.
A quick net search found the following:
64 kB (correct for 64 000, but the wrong concept) 6 581 hits
64 kb (meaningless) 64 256 hits
64 KB (meaningless) 25 329 hits
64 Kb (meaningless) 18 339 hits
64 KiB (the one truly correct form) 20 hits
Despite the standard no one uses the correct form. I find the kibi/mebi prefixes rather pedantic and not at all intuitive. However, the fact that a clause like "128 kb of memory" conveys no meaning (is that bits or bytes?) is quite disturbing. Mebi it is time to amend our ways and speak in more precise terms.