Subject: | Square root of negative value |
Date: | Thu, 27 Aug 2009 02:34:48 -0400 (EDT) |
To: | bug-Geo-Distance [...] rt.cpan.org |
From: | Mike Lieberman <codepoet [...] umiacs.umd.edu> |
Hello,
Thanks for a very useful module. I have noticed that certain values of
the latitude and longitude cause Geo::Distance to attempt a negative
square root when using the Haversine formula. For example, the following:
my $geo = Geo::Distance->new;
$geo->distance("mile", 175, 12, -5, -12);
Produces this:
Can't take sqrt of -2.22045e-16 at Geo/Distance.pm line 259.
I suspect this is some floating-point error happening but I don't know of
a good way to fix it - maybe adding some small epsilon to each coordinate
if they sum to 180? I am using perl 5.10 on Linux 2.6.28.
Best,
Mike Lieberman