Boost logo

Boost :

From: Rozental, Gennadiy (gennadiy.rozental_at_[hidden])
Date: 2003-10-30 13:24:05

> Personally I would prefer a fraction to a percentage.

Why? Message with percentage would look much more expressive:

a = 0.00023;
b = 0.00024;
BOOST_CHECK_CLOSE( a, b, 0.1 );

error in ... : difference between a(0.00023) and b(0.00024) exceed 0.1%

> New names for this MACRO(s)?

These looks too long

> BOOST_CHECK_CLOSE_RELATIVE(real1, real2, fraction) (real1 - real2) /
> real1 < fraction

> and

> BOOST_CHECK_CLOSE_ABSOLUTE(real1, real2, difference) (real1 - real2)
> < difference

I still not sure we need special tool for absolute closeness check. One
thing though I do consider to add. It appears that many users of
BOOST_CHECK_CLOSE need in fact to check that the value is small or iow close
to zero with some tolerance. Relative closeness wouldn't work in this case
cause relative difference between any value and zero is 100%. I propose tool
that perform namely this kind of check:

BOOST_CHECK_SMALL( a, 1e-10 ) // checks |a| < 1e-10

I am not sure about the name though.

> perhaps

> Paul


| I have several outstanding issues with BOOST_CHECK_CLOSE. Users keeps
| confuse it with absolute comparison and error message is misleading.
| What I plan is to switch to percentage based specification of the
| tolerance. IOW BOOST_CHECK_CLOSE( a, b, p ) will check that (a-b)/a
does not
| exceed p percent. Error message I will change accordingly.
| The only problem is that will not be backward compatible. Does
anybody see
| a solution to overcome this?
| Gennadiy.

Boost list run by bdawes at, gregod at, cpdaniel at, john at