develooper Front page | perl.perl5.porters | Postings from July 2018

[perl #41202] text->float conversion gives wrong answer

Thread Previous
From:
sisyphus@cpan.org via RT
Date:
July 14, 2018 20:18
Subject:
[perl #41202] text->float conversion gives wrong answer
Message ID:
rt-4.0.24-10143-1531570928-1000.41202-15-0@perl.org
On Sun, 11 Mar 2018 04:11:50 -0700, sisyphus wrote:
> Le Fri, 09 Mar 2018 22:47:01 -0800, sisyphus a écrit :
> 
> > Annoyingly, on the Windows 'long double' build only, the patch altered
> > the way that the numification of the string '9875'x1000 alters the
> > internals. (This caused one Math::MPFR test to fail, and I need to
> > investigate it.)
> 
> Looks to me like a mingw runtime bug in strtold() - which I've reported to:
> https://sourceforge.net/p/mingw-w64/bugs/711/

The bug turns out to be easily worked around. Attached is the patch I eventually used with perl-5.28.0.
On the systems I've tested, it works flawlessly and I've yet to find a value that gets assigned incorrectly on either "double" builds or extended precision "long double" builds or "__float128" builds of perl.
It also does not cause any of the tests (in the perl-5.28.0 test suite) to fail.

The systems I've tested have been Ubuntu-16.04 (gcc-5.4.0 &, glibc-2.23), Debian Wheezy (gcc-4.6.3 & glibc-2.13) and MS Windows (various mingw-w64 ports of gcc-4.7.0 thru to 8.1.0).

I'm therefore unaware of any valid reason that this modified patch should not be incorporated into perl-5.29.
If objections exist, please raise them so that I can attend to them.

The effects of this patch can be nullified by building perl such that HAS_STRTOD or HAS_STRTOLD is not defined. On Linux this is as simple as configuring the perl build with -Ud_strtod or -Ud_strtold.

I've given a little more detail at https://www.perlmonks.org/?node_id=1217588

Cheers,
Rob

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=41202

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About