
"John Maddock" <john@johnmaddock.co.uk> wrote in message news:004001c7970b$6a2dcf50$ddff1b52@fuji...
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 as a persent
or:
BOOST_CHECK_FRACTION(a, b, N*numeric_limits<T>::epsilon()); // tolerance as 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. Generally 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? Gennadiy