Date: Thu, 09 May 2019 17:12:35 +0000 From: bugzilla-noreply@freebsd.org To: numerics@FreeBSD.org Subject: [Bug 237800] pow(3) returns inaccurate results Message-ID: <bug-237800-18636-zvuHmKBoQx@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-237800-18636@https.bugs.freebsd.org/bugzilla/> References: <bug-237800-18636@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D237800 --- Comment #7 from Karl Williamson <khw@cpan.org> --- (In reply to Peter Jeremy from comment #3) There's nothing in the ticket that indicates perl is using pow() to convert between strings and floating point values. To do that, it instead uses a c= all to a C library function: some strtod() flavor, which particular one depends= on the desired precision, and what is available on the platform, determined by configuration options at the time the perl executable is compiled. If those options indicate to use long doubles, it will use strtodl(), for example. However, it used to be that perl used atof() in some circumstances instead = of when it otherwise could use plain strtod(). Perl does use pow() when performing an exponentiation operation and regular doubles were requested at perl compilation time. This module does exponentiation. The maintainer of the module discovered that the results of that operation were sometimes wrong, and further somehow figured out that if the floating point value was stringified and then reparsed by perl, that the value magically was corrected. Statements s/he wrote in the perl language expand to do a C library sprintf and then an atof on that result. Except t= hat now it's sprintf followed by strtod. But it turns out that the magic was only because of the poorer precision offered by atof(), and when perl converted to not ever use atof, the workar= ound failed. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-237800-18636-zvuHmKBoQx>