Boost C++ Libraries: Ticket #2268: BOOST_CHECK_CLOSE returns only errors https://svn.boost.org/trac10/ticket/2268 <p> Hi all </p> <p> This is my first bug report (ticket) to the boost developer team or to whom it may concern. So please don't be angry about some mistakes :-) </p> <p> I think I have found a bug in the test library. I have to check some double values near zero. </p> <p> The first one seems to be ok: </p> <pre class="wiki">BOOST_CHECK_CLOSE( P(0,0), PostMatrix(0,0), 1e-20 ); </pre><p> This returns: </p> <p> ../src/nnetDataProcessingTest.h(341): error in "NnetDataProcessing_testPostStd1": difference between P(0,0)<a class="report" href="https://svn.boost.org/trac10/report/1">{1}</a> and <a class="missing wiki">PostMatrix</a>(0,0){0.99999999999999978} exceeds 1e-20% </p> <p> If I set the tolerance to 1e-6, everything is ok! </p> <p> Now, the second one seems to contain the bug: </p> <pre class="wiki">BOOST_CHECK_CLOSE(0.0,-2.3093506e-17,1); </pre><p> You see, I have written some double values directly in the BOOST_CHECK_CLOSE to be sure I don't have a mistake somewhere else. The tolerance is set to 1%! But even though I get following message: </p> <p> <strong><em>'../src/nnetDataProcessingTest.h(361): error in "NnetDataProcessing_testPostStd1": difference between 0.0<a class="missing report" title="report does not exist">{0}</a> and -2.3093506e-17{-2.3093506000000001e-17} exceeds 1%</em></strong>' </p> <p> This is not the expected result? Waht's wrong here. Is this my mistake? Or is it really a bug? </p> <p> Thanks for any help </p> <p> Michael </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2268 Trac 1.4.3 Marshall Clow Tue, 09 Sep 2008 18:54:45 GMT component changed; owner set https://svn.boost.org/trac10/ticket/2268#comment:1 https://svn.boost.org/trac10/ticket/2268#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Gennadiy Rozental</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">test</span> </li> </ul> Ticket Gennadiy Rozental Sat, 13 Sep 2008 09:05:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2268#comment:2 https://svn.boost.org/trac10/ticket/2268#comment:2 <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">invalid</span> </li> </ul> <p> Short answer: no FP value is close to zero, but zero. For details please read references in documentation. </p> <p> If you need to check that the value is "close to zero" as in it's has very small absolute value - use BOOST_CHECK_SMALL instead </p> Ticket