in reply to When 1e-298L != 1e-298L

Is there a sound reason for this variation in value ?

When I finally got my thinking straightened out, it became obvious to me that this is a perl bug.
However, just because it's "obvious to me" doesn't really prove that it *is* a bug, so I've sent off a perlbug report (ticket #120363) ... if I don't forget, I'll update this node with the outcome of that report.

Thanks again Ken and Buk.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: When 1e-298L != 1e-298L
by syphilis (Archbishop) on Nov 01, 2013 at 13:42 UTC
    I'll update this node with the outcome of that report

    Seems it's a known bug (ticket #41202 from nearly 3 years ago) - and perhaps it's worthy of a separate post instead of an update.

    I haven't found a build of perl that's not affected (and I've got quite a few) across intel (MS Windows), amd64 (Ubuntu) and PowerPC (debian) machines.
    However, on some systems it's an off-by-one discrepancy , whereas on other systems it's off-by-two. (These could well be different bugs.)
    And it seems to not occur across the full range of exponents ... so, for most perl purposes it's probably not much of an issue.

    Still, it annoyed me enough to write a Math::NV module whose nv($str) function will assign the "C" value of $str to an NV - the assumption being that "C" gets it right. (It's an assumption I've tested against what both Data::Float and the mpfr library reckon is the correct representation but, with so many different versions of compiler/libc around, there's always a possibility of a bug to muddy the waters.)

    Cheers,
    Rob