[Bug 237800] pow(3) returns inaccurate results

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu May 9 17:12:37 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237800

--- Comment #7 from Karl Williamson <khw at 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 call
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 that
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 workaround
failed.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-numerics mailing list