Boost C++ Libraries: Ticket #10173: Epsilon value returned by std::numeric_limits is too small on PowerPC, causing tests to fail https://svn.boost.org/trac10/ticket/10173 <p> In <code>lexical_cast_float_types_test</code>, <code>std::numeric_limits&lt;long double&gt;::epsilon()</code> is used as a tolerance value when comparing long double values to check the accuracy of lexical_cast. </p> <p> 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: </p> <p> <code>x + x * eps != x for all x</code> </p> <p> This value can be found by calculating 2<sup>(1-D), where D is the number of bits of precision in the type. </sup></p> <p> We found this same issue in many parts of the Boost math library, and resolved it by adding a special case of <code>boost::math::tools::epsilon&lt;long double&gt;</code> 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: </p> <p> <a class="ext-link" href="https://github.com/boostorg/math/blob/7cb3316d0616db01f6c4a56126d4bf8c73e7b50d/include/boost/math/tools/precision.hpp#L160-178"><span class="icon">​</span>https://github.com/boostorg/math/blob/7cb3316d0616db01f6c4a56126d4bf8c73e7b50d/include/boost/math/tools/precision.hpp#L160-178</a> </p> <p> I have created a pull request which replaces all instances of <code>std::numeric_limits&lt;T&gt;::epsilon()</code> with <code>boost::math::tools::epsilon&lt;T&gt;</code> in <code>lexical_cast_float_types_test</code>. 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: </p> <p> <a class="ext-link" href="https://github.com/boostorg/lexical_cast/pull/3"><span class="icon">​</span>https://github.com/boostorg/lexical_cast/pull/3</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10173 Trac 1.4.3 Antony Polukhin Mon, 11 Aug 2014 10:22:13 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/10173#comment:1 https://svn.boost.org/trac10/ticket/10173#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> <p> Fix was applied to the <a class="ext-link" href="https://github.com/boostorg/lexical_cast/commit/2cabcbdf0f98cc4ce131b9ca78847b62678cebf9"><span class="icon">​</span>develop branch</a> and already merged to the master branch. </p> Ticket