Boost logo

Boost Users :

From: Will Bryant (will_at_[hidden])
Date: 2005-09-23 20:28:53


Gennadiy Rozental wrote:

>I chose to divide percent tolerance by 100 (multiplication would lead to
>overflow issues). BOOST_CHECK_CLOSE doesn't really fit for integral type
>closeness check. You could use BOOST_CHECK_SMALL instead.
>
>
>
Would it not be useful to provide a specialisation of the comparison
template for integral types? The current semantics aren't useful IMHO -
they just give undocumented false test passes - so even a naive
implementation which risked overflow would be an improvement.

But we can actually prevent overflow - just check if |a-b| is >= the
maximum value for the integer type / 100, if not use 100*|a-b|/a, if so
use something like |a-b|/(a/100).

Will

-- 
Will Bryant
http://carcino.gen.nz/
will_at_[hidden]
+64 21 655 443

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net