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.


In reply to test fails on 64bit uselongdouble Perl by frankcox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.