[test] Floating point comparison update

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, Gennadiy

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.

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental Sent: 24 December 2008 04:45 To: boost@lists.boost.org Subject: [boost] [test] Floating point comparison update
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
Excellent - will be Really Useful. Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com
participants (3)
-
Gennadiy Rozental
-
John Maddock
-
Paul A. Bristow