That is 99.99999999999999780441116897988% error. 16 9's is better than any 
measuring instrument in existence. I think it'll do:)

--------
Paul Anderson -- VE3HOP

On 2012-08-30, at 1:29 AM, Jim Gibson <jimsgib...@gmail.com> wrote:

> 
> On Aug 29, 2012, at 5:53 PM, Chris Stinemetz wrote:
> 
>> Just one question. If the two sets of coordinates are the same I was
>> expecting the distance to be 0 miles.
>> 
>> Instead I get:
>> 
>> 2.19558883102012e-013
>> 
>> For the following example.
>> 
>> #!/usr/bin/perl
>> 
>> use strict;
>> use warnings;
>> 
>> use feature qw(say);
>> use Geo::Ellipsoid;
>> 
>> my $lat1 = 39.316858;
>> my $lat2 = 39.316858;
>> my $lon1 = -94.963194;
>> my $lon2 = -94.963194;
>> 
>> 
>> my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
>> say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);
>> 
>> If it is the expected outcome would you please explain why?
> 
> 
> Because floating-point arithmetic as done by limited precision computers is 
> always an approximation. An IEEE 754 double-precision 64-bit floating point 
> number uses a 53-bit fraction and therefore has about 16 decimal digits of 
> precision. So calculating zero within 13 digits (e-013) is pretty good.
> 
> The calculation done by the Geo::Ellipsoid module is very complex and 
> involves sines, cosines, tangents, etc. Precision will be lost with each 
> floating-point operation.
> 
> Have you worked out what 2e-13 miles is in inches? For all practical 
> purposes, it IS zero.
> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to