
Please don't top post. Rearranged: Glenn Schrader writes:
Hugo Duncan wrote:
Hi,
Just to chime in with my problems using BOOST_CHECK_CLOSE ...
I always have problems when checking for small numbers or zero. I write something like BOOST_CHECK_CLOSE(0,x,1e-5) and start wondering why it fails, then rewrite the test using an epsilon value.
When I know the value is going to be near zero this is ok, but sometimes tests are written for computed values. A possible solution would be to have a check that uses the maximum of a relative and an absolute tolerance.
Hmmm.
An absolute difference is:
BOOST_CHECK_CLOSE( x, y, 1e-5 );
True??
Uh, no, I don't think so. IIRC BOOST_CHECK_CLOSE does a relative error check.
so wouldn't a relative difference be:
BOOST_CHECK_CLOSE( x / y, 1, 1e-5); or equivalently BOOST_CHECK_CLOSE( x, y, abs(y) * 1e-5); or maybe even BOOST_CHECK_CLOSE( x, y, max(abs(x),abs(y)) * 1e-5);
No, that's not what BOOST_CHECK_CLOSE does, unless it's changed since 1.33.1 (which is what I'm looking at). The discussion here is, very approximately, that since it's not immediately obvious _what_ kind of test is being done in BOOST_CHECK_CLOSE because of the name, and that this causes confusion. ---------------------------------------------------------------------- Dave Steffen, Ph.D. Fools ignore complexity. Software Engineer IV Pragmatists suffer it. Numerica Corporation Some can avoid it. ph (970) 461-2000 x227 Geniuses remove it. dgsteffen@numerica.us -- Alan Perlis ___________________ Numerica Disclaimer: This message and any attachments are intended only for the individual or entity to which the message is addressed. It is proprietary and may contain privileged information. If you are neither the intended recipient nor the agent responsible for delivering the message to the intended recipient, you are hereby notified that any review, retransmission, dissemination, or taking of any action in reliance upon, the information in this communication is strictly prohibited, and may be unlawful. If you feel you have received this communication in error, please notify us immediately by returning this Email to the sender and deleting it from your computer.