How to Annoy a Math Major

A friend of mine recently started college. I can’t specifically remember what degree plan he settled on–whether electrical engineering or computer science–but I woke up this morning with a humorous (and very geeky) joke in mind that I would like for him to share with his peers. Now, bear with me, because it was insanely funny to me when I first woke up still groggy from the morning haze. As sanity returned, however, the joke seemed markedly less amusing. Here goes:

Q: How might a CS student annoy a first year math major?
A: 0.1 + 0.2 ≈ 0.3

You might find the statement absurd. After all, it truly seems to make little sense that 0.1 plus 0.2 is approximately equal to 0.3. One-tenth and two-tenths equals three-tens. End of story. Right?

Therein lies the problem that first year math students might not appreciate (and one that hopefully CS students would!): Qualify the number base! In base 10, it’s easy enough to represent certain fractions (think 1/10th, 2/5ths, etc.) in a concise decimal representation such as 0.1 or 0.2. Of course, this breaks down with other fractions like 1/3rd or 2/3rds where the decimal representation would be 0.666666 ad infinitum. Incidentally, this is exactly why in the wonderful world of technology, you really can wind up in a situation where 0.1 + 0.2 isn’t exactly 0.3. Just as 1/3rd cannot be represented in decimal without repetition notation, 0.1 (or 1/10th) is a repeating fraction in binary (0.000110011001100110011001100110011…); thus, once the floating point is converted from its binary representation to a human readable format (rather, converting base 2 to base 10), 1/10th (in binary) would appear as 0.100000000000000005551115123126… and so on.

For further examples and a much better description of why this happens than I can write go here.

Edit: October 18. This post was meant as a jestful commentary on number bases and to highlight unexpected issues that aspiring CS majors may run into as they learn to code. I find it necessary to point this out because I have had some acquaintances with heavy mathematics backgrounds grow infuriated with me because they felt that I gloss over a few glaring points (which is intentional). Amusingly, I don’t think they read the title. :)

No comments.
***