|
Boost Users : |
Subject: Re: [Boost-users] [boost.test] Floating point comparisons
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2010-11-23 01:55:28
Anders Wang Kristensen <awk.main <at> gmail.com> writes:
> If either entry is zero, I can use BOOST_CHECK_SMALL instead with an
> absolute error:
>
> if (ref==0.0 || val==0.0)
> BOOST_CHECK_SMALL(ref - val, absolute_error);
> else
> BOOST_CHECK_CLOSE(ref, val, relative_error);
>
> But is this really the best way to do this?
Looks reasonable
> And if this is the
> standard way of doing this, shouldn't there be function in boost.test
> for automating this, like:
> BOOST_CHECK_NEAR(ref, value, relative_error, absolute_error);
This may or may not be generally useful. And it does not write specifica
variation you need for yourself.
Gennadiy
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