frankcox has asked for the wisdom of the Perl Monks concerning the following question:
I recently added a new test to Geo::ReadGRIB and started getting fails from CPAN Testers only on 64bit Perls where nvtype='long double' and nvsize= 12 or 16.
I found the problem is in a floating point calculation for some values of the variables. The problem code fragment is:
$out = (( ($lat - $self->La1) / $self->LaInc ) * $self->Ni) + (($thislong ) / $self->LoInc); return sprintf "%d", $out;
This will work for most values but as an example of the problem, the following test will fail on 64bit uselongdouble Perls:
my $calc = sprintf "%d",(((63 - -90)/.6) * 601) + (360 /.6); ok( $calc == 153855 ) or diag ("((63 - -90)/.6) * 601) + (360 /.6) = 153855 not $calc ");
This test will pass on any other CPAN Tester platform and 153855 is what I get if work this by hand.
My module will not work correctly if this code returns the wrong value. Is there any way I can modify the code to get the expected result on any version of Perl?
Another option is to detect uselongdouble in Makefile.PL and not build on the problem systems. I'd rather not do that.
Thank you for considering my problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: test fails on 64bit uselongdouble Perl
by ikegami (Patriarch) on Oct 29, 2009 at 19:04 UTC | |
by frankcox (Acolyte) on Oct 29, 2009 at 19:18 UTC | |
by moritz (Cardinal) on Oct 29, 2009 at 19:30 UTC | |
by frankcox (Acolyte) on Oct 29, 2009 at 19:47 UTC | |
by ikegami (Patriarch) on Oct 29, 2009 at 20:41 UTC | |
| |
by frankcox (Acolyte) on Oct 29, 2009 at 20:04 UTC | |
by ikegami (Patriarch) on Oct 29, 2009 at 20:31 UTC | |
by frankcox (Acolyte) on Oct 29, 2009 at 21:13 UTC | |
by moritz (Cardinal) on Oct 29, 2009 at 21:44 UTC | |
| |
by ikegami (Patriarch) on Oct 29, 2009 at 21:19 UTC | |
| |
|
Re: test fails on 64bit uselongdouble Perl
by moritz (Cardinal) on Oct 29, 2009 at 17:53 UTC | |
by frankcox (Acolyte) on Oct 29, 2009 at 18:40 UTC | |
by frankcox (Acolyte) on Oct 29, 2009 at 19:07 UTC | |
|
Re: test fails on 64bit uselongdouble Perl
by frankcox (Acolyte) on Oct 30, 2009 at 01:06 UTC | |
by frankcox (Acolyte) on Oct 30, 2009 at 23:49 UTC |