|
Boost Users : |
Subject: Re: [Boost-users] [Boost.UTF] Strange (failed) result on comparing floats
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-03-31 10:35:01
AMDG
Olaf Peter wrote:
> I'm checking some data of consistence using boost's unit test framework
> (1.42):
>
> BOOST_CHECK_CLOSE( *v[1].y.max, -43.0e-3,
> std::numeric_limits<double>::epsilon() );
>
> which fails with:
>
> difference{1.6137e-14%} between *v[1].y.max{-0.043000000000000003} and
> -43.0e-3{-0.042999999999999997} exceeds 2.2204460492503131e-16%
>
> where v is a std::vector,y a struct and max a boost::optional<double>.
> The data where parsed by boost.spirit. This is the only failed test case
> from 16 parsed doubles. What's gone wrong here? Do I miss something?
>
epsilon is too small. BOOST_CHECK_CLOSE treats the
argument as a percent, so there's an extra factor of 0.01, which
means that this comparison is effectively for equality.
In Christ,
Steven Watanabe
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