|
Boost : |
Subject: Re: [boost] [test] Floating point comparison update
From: John Maddock (john_at_[hidden])
Date: 2008-12-24 04:49:25
Gennadiy Rozental wrote:
>> Hi,
>>
>> I've checked in 2 changes to the floating point comparison tools.
>>
>> 1. BOOST_CHECK_CLOSE now can compare values of different types:
>>
>> BOOST_CHECK_CLOSE( 2, 2.1, 6 ); // compare and and double
>> BOOST_CHECK_CLOSE( 2.1, 2, 6 ); // compare double and int
>> BOOST_CHECK_CLOSE( 2.1, 2.f, 6 ); // compare double and float
>>
>> 2. Floating point comparison tools now report difference if any:
>>
>> BOOST_CHECK_CLOSE( 2, 2.1, 3 ) will lead to:
>>
>> difference{4.7619%} between 2{2} and 2.1{2.1} exceeds 3%
>>
>> BOOST_CHECK_CLOSE_FRACTION( 2, 2.1, 0.04 ) will lead to:
>>
>> difference{0.047619} between 2{2} and 2.1{2.1} exceeds 0.04
>>
>> Any comments appreciated,
Yeh!
Thanks Gennadiy, that'll be a big help,
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk