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 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…

Do you need to eliminate bugs in your firmware? Shorten schedules? My one-day Better Firmware Faster seminar will teach your team how to operate at a world-class level, producing code with far fewer bugs in less time. It's fast-paced, fun, and covers the unique issues faced by embedded developers. Here's information about how this class, taught at your facility, will measurably improve your team's effectiveness.