|
Boost : |
Subject: Re: [boost] [test] Floating point comparison update
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2008-12-24 07:06:09
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
On
> Behalf Of Gennadiy Rozental
> Sent: 24 December 2008 04:45
> To: boost_at_[hidden]
> 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_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk