[Boost-bugs] [ boost-Bugs-1553359 ] floating point comparison algorithm

Bugs item #1553359, was opened at 2006-09-06 04:59 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1553359&group_id=7586 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: test Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Beman Dawes (beman_dawes) Summary: floating point comparison algorithm Initial Comment: The floating point comparison algorithm does not seem to work if one of the floating points is zero and the other one is close to zero. Here's the code sample I've used: close_at_tolerance<double> checker(0.01); const double a = 0.0; const double b = 0.0000001; bool res = checker(a, b); if (!res) { std::cerr << "ERROR" << std::endl; } I think the following check must be added in the close_at_tolerance<FPT>::operator() function: bool operator()( FPT left, FPT right ) const { if (left == 0.0 || right == 0.0) { return (p_fraction_tolerance.get() > tt_detail::fpt_abs(left-right)); } // ... } My email address is "tom.vanroey@vito.be". ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1553359&group_id=7586 ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Boost-bugs mailing list Boost-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs

"SourceForge.net" <noreply@sourceforge.net> wrote in message news:E1GKw3s-0007FA-S2@sc8-sf-web6.sourceforge.net...
Assigned to: Beman Dawes (beman_dawes)
Why did this get assiigned to Beman? Is he default assignee?
Summary: floating point comparison algorithm
Initial Comment: The floating point comparison algorithm does not seem to work if one of the floating points is zero and the other one is close to zero. Here's the code sample
[...] This is intentional. According my understanding of numeric computations no value is close to zero with any tolerance. If you indeed want to test that the value is small, use check_is_small/BOOST_CHECK_SMALL instead. If you want to check closeness of two values, don't check the difference with zero. Use the BOOST_CHECK_CLOSE directly with values you are comparing. Gennadiy
participants (2)
-
Gennadiy Rozental
-
SourceForge.net