21 Sep
2005
21 Sep
'05
2:59 p.m.
"Will Bryant"
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