[test] Confusion about BOOST_CHECK_CLOSE

I have re-read everything I can find about BOOST_CHECK_CLOSE, and the doc on floating point comparison algorithms (i.e.close_at_tolerance). However, I am still confused about how to use BOOST_CHECK_CLOSE. Could we have some clear examples of comparisons that pass/fail with different tolerance settings, and some explanation as to how changing the tolerance may affect the test? Currently, I have a test, using BOOST_CHECK_CLOSE() which passes, no matter how big/small I set the tolerance; yet the values are different. Thanks!

As it happens, I am also just now using this to check my collection of high accuracy man constants and I am similarly confused. If I want to check that two values differ by not more than just one binary ULP (least significant bit), is the BOOST_CHECK_CLOSE tolerance numeric_limits<double>::epsilon() * 100.? *100. because tolerance is in percent - sniff ;-) Thanks Paul Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539 561830 +44 7714 330204 mailto: pbristow@hetp.u-net.com | -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Jody Hagins | Sent: 25 May 2005 17:06 | To: boost@lists.boost.org | Subject: [boost] [test] Confusion about BOOST_CHECK_CLOSE | | | I have re-read everything I can find about BOOST_CHECK_CLOSE, and the | doc on floating point comparison algorithms (i.e.close_at_tolerance). | | However, I am still confused about how to use | BOOST_CHECK_CLOSE. Could | we have some clear examples of comparisons that pass/fail | with different | tolerance settings, and some explanation as to how changing the | tolerance may affect the test? | | Currently, I have a test, using BOOST_CHECK_CLOSE() which passes, no | matter how big/small I set the tolerance; yet the values are | different. | | Thanks! | | _______________________________________________ | Unsubscribe & other changes: | http://lists.boost.org/mailman/listinfo.cgi/boost |

If I want to check that two values differ by not more than just one binary ULP (least significant bit), is the BOOST_CHECK_CLOSE tolerance
numeric_limits<double>::epsilon() * 100.?
*100. because tolerance is in percent - sniff ;-)
Documentation explicitly emphasize that tolerance is in percents. Previously there was a lot of confusion, when people tried to employ this check to do absolute comparisons. Now it's clear - comparisons are relative (to the value modules) Gennadiy

"Jody Hagins" <jody-boost-011304@atdesk.com> wrote in message news:20050525120541.09fd4705.jody-boost-011304@atdesk.com...
I have re-read everything I can find about BOOST_CHECK_CLOSE, and the doc on floating point comparison algorithms (i.e.close_at_tolerance).
BOOST_CHECK_CLOSE( x, y, t ) checks that x and y does not differ for more then t persent. IOW: |x-y|/|x| < t and |x-y|/|y| < t
Currently, I have a test, using BOOST_CHECK_CLOSE() which passes, no matter how big/small I set the tolerance; yet the values are different.
Could you show your tests and Boost.Test output. Gennadiy

LOL Hoist on your own petard ;-) This is why I don't like percent - but please don't change it now. Paul | -----Original Message----- | From: boost-bounces@lists.boost.org | [mailto:boost-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental | Sent: 25 May 2005 18:24 | To: boost@lists.boost.org | Subject: [boost] Re: [test] Confusion about BOOST_CHECK_CLOSE | | > |x-y|/|x| < t and |x-y|/|y| < t | | Sorry: | | |x-y|/|x| < t/100 and |x-y|/|y| < t/100 | | Gennadiy | | | | _______________________________________________ | Unsubscribe & other changes: | http://lists.boost.org/mailman/listinfo.cgi/boost |
participants (3)
-
Gennadiy Rozental
-
Jody Hagins
-
Paul A Bristow