Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Test] Understanding the correct use of BOOST_CHECK_CLOSE and BOOST_CHECK_CLOSE_FRACTION
From: Torri, Stephen CIV NSWCDD, W15 (stephen.torri_at_[hidden])
Date: 2010-09-09 09:44:13


I am trying to understand how to be use BOOST_CHECK_CLOSE and BOOST_CHECK_CLOSE_FRACTION for my problem. My problem is being able to check that two floating point values agree within 12 decimal digits. That is the difference between the two values is smaller than 1e-12. I see from the documentation that BOOST_CHECK_CLOSE requires a percent of agreement while BOOST_CHECK_CLOSE_FRACTION requires a fraction value. So when I used BOOST_CHECK_CLOSE_FRACTION to compare two value I got output that I didn't know how to read:
 
/test_sgp4_orbit_data.cpp(52): error in "default_calculate_semi_major_test": difference{1e-12} between result{1.1219271770198256} and 1.1219271773271688{1.1219271773271688} exceeds 9.9999999999999998e-13

I used BOOST_CHECK_CLOSE_FRACTION as:
 
 BOOST_CHECK_CLOSE_FRACTION ( result, 1.1219271773271688, 1e-12 );
 
What I am intending is if 'result' and the value differ by more than 1e-12 then I have an error. If the difference is smaller than 1e-12 I wish to have the comparison succeed. From the output I don't know why the exceeds value is not written as '1e-12' since that is what I used.
 
Where am I going wrong in my use of BOOST_CHECK_CLOSE_FRACTION?
 
Stephen
 
Stephen Torri, PhD
NAVAL SURFACE WARFARE CENTER DAHLGREN
17214 Ave B Suite 121
Dahlgren, Va. 22448
540-653-1082
I am not a contracting officer. I cannot modify or initiate contracts, nor do I have the authority to financially commit the government in any way.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net