Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] floating point comparison
From: Matthijs Möhlmann (matthijs_at_[hidden])
Date: 2013-10-30 11:32:26


On 10/30/13, 3:00 PM, Pekka Seppänen wrote:
> On 30.10.2013 15:40, Matthijs Möhlmann wrote:
>> Hello all,
>>
>> I've the following test program:
>>
>> BOOST_AUTO_TEST_CASE(TestCase) {
>>
>> BOOST_REQUIRE_CLOSE_FRACTION(45.00f, 45.17f, 0.004f);
>> }
>>
>> If I lower the tolerance to 0.0004f then I'll get the following:
>> Running 1 test case...
>> main.cpp(8): fatal error in "TestCase": difference{0.00376352} between
>> 45.00f{45} and 45.17f{45.1699982} exceeds 0.00039999999
>>
>> *** 1 failure detected in test suite "Master test suite"
>>
>> Why does it say that the difference is 0.00376352 and not 0.17....... ?
>>
>
> Hi,
>
> it's because the tolerence is given in *percentage units*. Thus, it
> naturally reports thats the difference (again, in percentage units is
> 0.0038%) exceeds the given limit (that was now 0.0004%).
>
> Not sure if your terminal just ommits the percentage signs. Maybe that
> was leading you off.
>
Hi,

What's then the difference between those two macro's:
BOOST_<level>_CLOSE and
BOOST_<level>_CLOSE_FRACTION ?

The documentation indicates that the third parameter is indeed
'percentage units' but according to the output of both
testcases in the documentation it suggests something else.

See
http://www.boost.org/doc/libs/1_54_0/libs/test/doc/html/utf/testing-tools/reference.html

Do you have some explanation for that maybe?

Regards,

Matthijs Möhlmann


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