Boost C++ Libraries: Ticket #725: floating point comparison algorithm https://svn.boost.org/trac10/ticket/725 <pre class="wiki">The floating point comparison algorithm does not seem to work if one of the floating points is zero and the other one is close to zero. Here's the code sample I've used: close_at_tolerance&lt;double&gt; checker(0.01); const double a = 0.0; const double b = 0.0000001; bool res = checker(a, b); if (!res) { std::cerr &lt;&lt; "ERROR" &lt;&lt; std::endl; } I think the following check must be added in the close_at_tolerance&lt;FPT&gt;::operator() function: bool operator()( FPT left, FPT right ) const { if (left == 0.0 || right == 0.0) { return (p_fraction_tolerance.get() &gt; tt_detail::fpt_abs(left-right)); } // ... } My email address is "tom.vanroey@vito.be". </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/725 Trac 1.4.3 Gennadiy Rozental Wed, 13 Sep 2006 17:20:58 GMT status changed https://svn.boost.org/trac10/ticket/725#comment:1 https://svn.boost.org/trac10/ticket/725#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=331868 Not a bug </pre> Ticket