Expert C Programming

(Jeff_L) #1
and reboot your machine.

It's as simple as that. And remember, Beethoven wrote his first symphony in C.


—A.P.L. Byteswap's Big Book of Tuning Tips and Rugby Songs


the Potrzebie system of weights and measures...making a glyph from bit patter ns...types changed while you wait...prototype painfulness...read a character
without newline...implementing a finite state machine in C...program the simple cases first...how and why to cast...some light relief—the inter national
obfuscated C competition


The Potrzebie System of Weights and Measures


Of course, when Picasso made the comment about computers being uninteresting, we know that he
was really seeking to advance a discourse in which it was the rôle of artists to challenge the
establishment, ask questions, or at least see that the correct serving of fries accompanied each order.
How appropriate, therefore, that this chapter opens with the old question among computer folk that
asks why programmers can't tell Halloween from Christmas Day. Before we provide the punchline,
we should say a few words about the work of world-class computer scientist Donald Knuth. Professor
Knuth, who has taught at Stanford University for many years, wrote the massive and definitive
reference work, The Art of Computer Programming, [1] and designed the TeX typesetting system.


[1] Professor Knuth later identified his long-standing colleague Art Evans as the Art in The Art


of Computer Programming book title. Back in 1967, when the series of volumes started to
appear, Knuth gave a semi-nar at Carnegie Tech. Knuth remarked that he was glad to see his
old friend Art Evans in the audience since he had named his series of books after him.
Everyone groaned in appreciation once they grasped the awful pun, and Art was more amazed
than anyone.


Later, when Knuth won the ACM's Turing Award, he ensured that the pun entered the official
record by mentioning Art again in his Turing Award Lecture. You can read it in
Communications of the ACM, vol. 17, no. 12, p. 668. Art claims that "it hasn't affected my life
much at all."


A little-known fact is that Professor Knuth's first publication was not in a prestigious peer-reviewed
scientific journal, but in a much more popular gazette. "The Potrzebie System of Weights and
Measures" by Donald Knuth appeared in MAD Magazine, issue number 33, in June 1957. The article,
by the very same Donald Knuth who later became known as an eminent computer scientist, parodied
the then-novel metric system of weights and measures. Most of Knuth's subsequent papers have
tended to be more conventional. We think that's a shame, and look for a return to roots. The basis of
all measurements in the Potrzebie system is the thickness of MAD Magazine's issue number 26.


Knuth's article was a consistent application of metric-decaded prefixes using units that were more
familiar to MAD readers, such as potrzebies, whatmeworrys, and axolotls. For many of MAD's readers
it was a gentle introduction to the concepts of the metric system. People in the U.S. just weren't
familiar with kilo, centi, and other prefixes, so Knuth's Potrzebie paved the way for a greater
understanding. Had the Potrzebie system actually been adopted, perhaps the later American
experiment with the metric system would have been more successful.


Like the Potrzebie system, the joke about programmers' confusion over Halloween and Christmas Day
depends on inside knowledge of numbering systems. The reason that programmers can't tell
Halloween from Christmas Day is because 31 in octal (base eight) equals 25 in decimal (base ten).
More succinctly, OCT 31 equals DEC 25!

Free download pdf