$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r77284 - trunk/boost/geometry/util
From: barend.gehrels_at_[hidden]
Date: 2012-03-09 08:31:45
Author: barendgehrels
Date: 2012-03-09 08:31:44 EST (Fri, 09 Mar 2012)
New Revision: 77284
URL: http://svn.boost.org/trac/boost/changeset/77284
Log:
[geometry] fix in comparing doubles (comparing e.g. 0 with 4e-19)
Text files modified: 
   trunk/boost/geometry/util/math.hpp |    12 +++++++++++-                            
   1 files changed, 11 insertions(+), 1 deletions(-)
Modified: trunk/boost/geometry/util/math.hpp
==============================================================================
--- trunk/boost/geometry/util/math.hpp	(original)
+++ trunk/boost/geometry/util/math.hpp	2012-03-09 08:31:44 EST (Fri, 09 Mar 2012)
@@ -44,11 +44,21 @@
 template <typename Type>
 struct equals<Type, true>
 {
+	static inline Type get_max(Type const& a, Type const& b, Type const& c)
+	{
+		return (std::max)((std::max)(a, b), c);
+	}
+
     static inline bool apply(Type const& a, Type const& b)
     {
+		if (a == b)
+		{
+			return true;
+		}
+
         // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17,
         // FUTURE: replace by some boost tool or boost::test::close_at_tolerance
-        return std::abs(a - b) <= std::numeric_limits<Type>::epsilon() * std::abs(a);
+        return std::abs(a - b) <= std::numeric_limits<Type>::epsilon() * get_max(std::abs(a), std::abs(b), 1.0);
     }
 };