# Embedded Muse 74 Copyright 2002 TGG September 5, 2002

You may redistribute this newsletter for noncommercial purposes. For commercial use contact info@ganssle.com.

EDITOR: Jack Ganssle, jack@ganssle.com

CONTENTS:

- Editor’s Note

- K and k

- Thought for the Week

- About The Embedded Muse

# Editor’s Note

My August column in Embedded Systems Programming (on-line at http://embedded.com/story/OEG20020729S0045) about engineering ethics continues to garner quite a bit of feedback. There’s an interesting site with some case histories at http://onlineethics.org/moral/LeMessurier/lem.html. I’m happy to see that the site is largely organized for use in educational settings. Thought problems encourage people to consider the implications of their actions. Recommended.

# K and k

We computer folks use the “kilo” prefix pretty arbitrarily, sometimes referring to 1024 (that CPU has a 64k address space) or sometimes as 1000 (he’s pulling down 200k+ per year!). I was surprised to discover that these terms have formal definitions.

The International System of Units (the metric system) defines prefixes and abbreviations for multiples of ten, as follows:

10**3 kilo (symbol k)

10**6 mega (symbol M)

10**9 giga (symbol G)

(There are many more, ranging from 10**-24 to 10**24, but that’s outside of a computer discussion).

None of these are a surprise to any developer, perhaps with the exception of the case used for the abbreviations. Note that the M for mega and G for giga are always capitalized. Why is this crucial? Consider that lower case “m” means milli, so if we casually specify 4 mB of RAM we’re asking for .004 bytes.

Now it gets interesting. The metric system does not specify units for binary multipliers, but those wacky folks at the International Electrotechnical Commission, with the support of the IEEE, NIST, and other organizations, have.

The system is:

2**10 kibi (symbol Ki) (one kibi is 1024)

2**20 mebi (symbol Mi) (one mebi is 1 048 576)

2**30 gibi (symbol Gi) (one gibi is 1 073 741 824)

To further refine things, a byte is abbreviated “B” (capital B, that is), and a bit is, well, “bit”.

This means:

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 expression 64 kB means exactly 64 000 bytes. We are not allowed to say “the Z80 has a 64 kB address range”, because that is wrong. The correct version is “the Z80 has a 64 KiB address range”.

We’re also never allowed to use KB or Kbit – these are undefined. “k” (lower case) and “Ki” have meaning; “K” does not.

So now there’s no excuse for confusion between bits and bytes, or powers-of-2 multiples and powers-of-10.

Since precision is an important facet of engineering I welcome these terms, though will find it hard to adjust my writing appropriately…

# Thought for the Week

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.

But now we know it’s wrong…