From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2007-05-16 01:36:59
"John Maddock" <john_at_[hidden]> wrote in message
> Jody Hagins wrote:
>> Here's a chance for someone to finally clear my understanding of how
>> to compare floating point value... please ?!?!?
> Let's say you want the tolerance to be N*eps where eps is the machine
> epsilon and N is you level of tolerance, then you can use either:
> BOOST_CHECK_CLOSE(a, b, N*100*numeric_limits<T>::epsilon()); // tolerance
> a persent
> BOOST_CHECK_FRACTION(a, b, N*numeric_limits<T>::epsilon()); // tolerance
> a fraction.
Yes. This looks correct with current interfaces.
> There are still a couple of things that can get you:
> 1) This will fail if one of a and b is zero and the other isn't.
> speeking you may want to treat all values below some threshold as
> "effectively zero", but what that threshold is depends on your use case.
> 2) This fails if a and b are both infinity, probably a Boost.Test bug.
You mean it should fail and it passes?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk