Weirdness

Andy Wardley abw at wardley.org
Tue Feb 26 10:24:23 GMT 2008


Dan Rowles wrote:
> I have encountered some weirdness with floating point numbers, and I was 
> hoping for your collective wisdom on what to do next.

That's just the way floating point numbers work.  Epsilon is your friend:

   use constant epsilon => 0.0000001;      # a suitably small number

   sub fp_equal {
      abs($_[0] - $_[1]) < epsilon;
   }

http://en.wikipedia.org/wiki/Machine_epsilon

A



More information about the london.pm mailing list