
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Jody Hagins Sent: 15 May 2007 18:22 To: boost@lists.boost.org Subject: Re: [boost] [test] comparing floating point values
On Tue, 15 May 2007 17:09:14 +0100 "John Maddock" <john@johnmaddock.co.uk> wrote:
Thanks, John!!!
I'm still not entirely sure I understand it, but it works ;-)
I tested it with a std::stringstream... in and out... and after setting the stream precision large enough, the values in/out compared and the test passed. I then used the same comparisons for the values when I save/restore via my own code, and it works there too.
A word of caution if you are using MSVC - there are some values for which your 'loopback', even with the sufficient number of decimal digits, does not work for a third of values (are 1 least significant bit off) in a narrow range, about 0.0001 - 0.0005. MS have declared this a 'feature': http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac... In practice this is unlikely to bite you - but during testing it might, if you demand equality BOOST_CHECK_EQUAL rather than using a BOOST_CHECK_CLOSE_FRACTION() with a single epsilon sized tolerance. HTH too. Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com