Subject: [Boost-bugs] [Boost C++ Libraries] #10173: Epsilon value returned by std::numeric_limits is too small on PowerPC, causing tests to fail
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-02 16:27:31
#10173: Epsilon value returned by std::numeric_limits is too small on PowerPC,
causing tests to fail
-------------------------------------------------+-------------------------
Reporter: Harris Munir <hamunir@â¦> | Owner: apolukhin
Type: Bugs | Status: new
Milestone: To Be Determined | Component:
Version: Boost Release Branch | lexical_cast
Keywords: lexical_cast_float_types_test, | Severity: Problem
epsilon |
-------------------------------------------------+-------------------------
In {{{lexical_cast_float_types_test}}}, {{{std::numeric_limits<long
double>::epsilon()}}} is used as a tolerance value when comparing long
double values to check the accuracy of lexical_cast.
On PowerPC, this epsilon value is extremely small for the long double
type. While the value is technically correct, since adding 1.0L to it does
in fact result in a distinct value, it is not suitable for use as a
tolerance value in this type of comparison. Instead, we need a value such
that:
{{{x + x * eps != x for all x}}}
This value can be found by calculating 2^(1-D), where D is the number of
bits of precision in the type.
We found this same issue in many parts of the Boost math library, and
resolved it by adding a special case of
{{{boost::math::tools::epsilon<long double>}}} for platforms that use the
strange "double-double" implementation of long double, such as PowerPC.
This change is now in the master branch and can be seen here:
https://github.com/boostorg/math/blob/7cb3316d0616db01f6c4a56126d4bf8c73e7b50d/include/boost/math/tools/precision.hpp#L160-178
I have created a pull request which replaces all instances of
{{{std::numeric_limits<T>::epsilon()}}} with
{{{boost::math::tools::epsilon<T>}}} in
{{{lexical_cast_float_types_test}}}. This change fixes 5222 of the 5255
failures that currently occur within the test on a PowerPC machine with
long double support enabled. The pull request can be found here:
https://github.com/boostorg/lexical_cast/pull/3
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10173> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC