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 Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/