NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Computers Silently Discard Information (Score:1)
I'm sorry, but Perl also silently discards information [perl.org]. (Yes, I know that .9repeating is equal to 1, but perl's implementation only stores an imperfect representation of that).
The problem is that processors are designed to do approximate math quickly, so most computer math ends up being approximate. Perl just happens to be using a closer approximation to what you expect, in this case.
Personally, I would prefer that Perl's DWIM resulted in preserving all information available, like (IIRC) Haskell does (of course, this is still limited by memory availability). Yes, this would be slower. But Perl usually is designed to be correct first and fast second.
Obviously, it's too late to do this with Perl 5 because of backward compatability concerns, and I'm not sure if this behavior is desirable in Perl 6.
Reply to This
Re: (Score:1)
One thing to remember is that many compilers and operating systems may help you down to road to discard this information. Perl compiled Intel C++ on Linux, for example, failed several floating point tests in Perl. By removing optimizations (that is, making the compiler generate code to do the math correctly), the tests were made to pass. Various operating systems and compilers occasionally include "fast" math libraries as well that do a similarly good job of providing optimized approximations. I would s
Re: (Score:1)