Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-09-21 09:59:18


"Will Bryant" <will_at_[hidden]> wrote in message
news:4331173C.7060405_at_core-dev.co.nz...
> Hi all,
>
> Is BOOST_CHECK_CLOSE supposed to work with integral types? I find that
> if I try:
>
> long var1 = 1001;
> BOOST_CHECK_CLOSE(var1, 2000L, 10L);
>
> under both MSVC 2005 and GCC 3.4, it'll pass, which is wrong as far as I
> can see - whereas:
>
> double var2 = 1001.0;
> BOOST_CHECK_CLOSE(var2, 2000.0, 10.0);
>
> fails as it should.
>
> Why is this? int has the same problem.

BOOST_CHECK_CLOSE algorithm involves division (it compared relative distance
with tolerance). |a-b|/|a| will always produce 0 for integral types. Which
is less then any tolerance you could specify.

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