Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2004-07-28 09:57:49


 BOOST_IS_SMALL would be useful - I've wanted it recently.

I'd still like to be able to specify in terms of number of abs eps, with one
or two say, as default?

However, having said that, I suspect your 'complainant' probably doesn't
want really this.

Paul

Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539 561830 +44 7714 330204
mailto: pbristow_at_[hidden]

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Rozental, Gennadiy
| Sent: 27 July 2004 21:30
| To: 'boost_at_[hidden]'
| Subject: RE: [boost] Boost Test Library: Bug in
| floating-point comparison?
|
| > Hi,
| >
| > I want to use the boost::test floating-point comparison
| > algorithms (Boost
| > 1.31.0) and wrote the following simple lines of code:
| >
| > double d1 = 0.2;
| > double d2 = 0.8;
| > double d3 = d2-d1-d1-d1-d1; // d3 should be zero
| >
| > bool b = boost::test_toolbox::check_is_close( d3, 0., 1e-3 );
| >
| > To my surprise, the return value b is FALSE, although d3
| > should be _very_
| > close to zero (and is 5.55112e-17 on my machine).
| >
| > Am I missing something or is this a bug in the test library?
| >
| > Thanks,
| > Michael
| >
| > --
| > Michael Kettner
| > kettner_at_[hidden]
|
| Read algorithm description. The algorithm compare "relative
| errors". In your
| case it's 1 and infinity. Definitely more then 1e-03. It you
| want to compare
| absolute values (which is not recommended in real life
| applications) you
| either could write you own predicate or wait a bit, while I
| am considering
| adding BOOST_IS_SMALL tool that will be responsible namely
| for this kind of
| test.
|
| Gennadiy.
| _______________________________________________
| Unsubscribe & other changes:
| http://lists.boost.org/mailman/listinfo.cgi/boost
|
|


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk