Perl-Critic / PPI

53 stars 44 forks source link

Fix bug where Solaris 80 bit long doubles on x86 hardware causes #173

Closed jmaslak closed 7 years ago

jmaslak commented 9 years ago

I noticed that this build was failing tests (evaulating 1_0E1_0) on Solaris 11.1 when using any x86 32 bit Perl built with longdouble support and the Sun compiler (cc: Sun C 5.13 SunOS_i386 2014/10/20). I suspect the note "Known to fail on 5.6.2" note on the test was not due to this, but due to the fact that it was 32 bit Perl using Intel's longdouble floating point, which is a somewhat unusual configuration these days.

While 10E10 and 10 * 10 * 10 both displayed as 100000000000 on a long double machine (32 bit with ld support compiled in), you will find that there are at least two representations of 10E10 differ: jmaslak@solaris:~/tt/PPI$ perl -e '$a=10 * 10 * 10;$b=10E10;print $a-$b, "\n"' 1.49011611938476562e-08

With 64 bit Perl or non-ld Perl, it returns 0 as expected.

I took a look into the Perl interpreter and basically stole s_mulexp10, which is what is used for the "E" notation. I suspect this code will be slightly slower than using 10**exponent (which uses the pow() function in the Perl interpreter), but it should be correct a lot more often.

wchristian commented 7 years ago

Thanks, this has been cherry-picked and released. :)