|
Boost : |
From: Paul A Bristow (pbristow_at_[hidden])
Date: 2007-05-16 05:42:26
>-----Original Message-----
>From: boost-bounces_at_[hidden]
>[mailto:boost-bounces_at_[hidden]] On Behalf Of Jody Hagins
>Sent: 15 May 2007 18:22
>To: boost_at_[hidden]
>Subject: Re: [boost] [test] comparing floating point values
>
>On Tue, 15 May 2007 17:09:14 +0100
>"John Maddock" <john_at_[hidden]> 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?FeedbackID=98770
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_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk