Opened 14 years ago
Closed 14 years ago
#2268 closed Bugs (invalid)
BOOST_CHECK_CLOSE returns only errors
Reported by: | Owned by: | Gennadiy Rozental | |
---|---|---|---|
Milestone: | Boost 1.37.0 | Component: | test |
Version: | Boost 1.36.0 | Severity: | Problem |
Keywords: | BOOST_CHECK_CLOSE | Cc: |
Description
Hi all
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 :-)
I think I have found a bug in the test library. I have to check some double values near zero.
The first one seems to be ok:
BOOST_CHECK_CLOSE( P(0,0), PostMatrix(0,0), 1e-20 );
This returns:
../src/nnetDataProcessingTest.h(341): error in "NnetDataProcessing_testPostStd1": difference between P(0,0){1} and PostMatrix(0,0){0.99999999999999978} exceeds 1e-20%
If I set the tolerance to 1e-6, everything is ok!
Now, the second one seems to contain the bug:
BOOST_CHECK_CLOSE(0.0,-2.3093506e-17,1);
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:
'../src/nnetDataProcessingTest.h(361): error in "NnetDataProcessing_testPostStd1": difference between 0.0{0} and -2.3093506e-17{-2.3093506000000001e-17} exceeds 1%'
This is not the expected result? Waht's wrong here. Is this my mistake? Or is it really a bug?
Thanks for any help
Michael
Change History (2)
comment:1 by , 14 years ago
Component: | None → test |
---|---|
Owner: | set to |
comment:2 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Short answer: no FP value is close to zero, but zero. For details please read references in documentation.
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