May 2012 Archives

Guess what this does ...

First, here's a one-liner:

    perl -de 'BEGIN {@DB::typeahead=("V ::","q")};1'

If you have a sense of what might be happening, you're probably an experienced Perl user. If you can accurately describe what's happening, you're an advanced user. If you can completely describe the output before you see it, you need psychiatric help.

Floating Point Rounding Errors

In Chapter 3 of my book, I mentioned offhand that sometimes you expect the number 5, but you get 4.99999999998 instead. I sort of punted on the explanation because it seemed to be a touch of a distraction. Naturally, chromatic called me on that and suggested I explain a bit more. As part of my explanation, I wrote a sample program that would print out the fractions used to build the mantissa of a number. For example, .75 is 1/2 + 1/4.

About Ovid

user-pic Have Perl; Will Travel. Freelance Perl/Testing/Agile consultant. Photo by http://www.circle23.com/. Warning: that site is not safe for work. The photographer is a good friend of mine, though, and it's appropriate to credit his work.