Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86501 - trunk/libs/serialization/example
From: ramey_at_[hidden]
Date: 2013-10-28 11:39:01


Author: ramey
Date: 2013-10-28 11:39:01 EDT (Mon, 28 Oct 2013)
New Revision: 86501
URL: http://svn.boost.org/trac/boost/changeset/86501

Log:
corrected # digits
corrected tests which compare floating point numbers to require max 1 digit difference

Text files modified:
   trunk/libs/serialization/example/demo_dll_a.hpp | 9 +++------
   trunk/libs/serialization/example/demo_dll_a.ipp | 8 ++------
   trunk/libs/serialization/example/demo_dll_b.hpp | 5 +++--
   trunk/libs/serialization/example/demo_dll_b.ipp | 4 ++--
   4 files changed, 10 insertions(+), 16 deletions(-)

Modified: trunk/libs/serialization/example/demo_dll_a.hpp
==============================================================================
--- trunk/libs/serialization/example/demo_dll_a.hpp Mon Oct 28 11:36:41 2013 (r86500)
+++ trunk/libs/serialization/example/demo_dll_a.hpp 2013-10-28 11:39:01 EDT (Mon, 28 Oct 2013) (r86501)
@@ -20,6 +20,7 @@
 #include <cstdlib> // for rand()
 #include <cmath> // for fabs()
 #include <cstddef> // size_t
+#include <boost/math/special_functions/next.hpp>
 
 #include <boost/config.hpp>
 #if defined(BOOST_NO_STDC_NAMESPACE)
@@ -245,13 +246,9 @@
         return false;
     if(v != rhs.v)
         return false;
- if(w == 0 && std::fabs(rhs.w) > 2 * std::numeric_limits<float>::round_error())
+ if(std::abs( boost::math::float_distance(w, rhs.w)) > 1)
         return false;
- if(std::fabs(rhs.w/w - 1.0) > 2 * std::numeric_limits<float>::round_error())
- return false;
- if(x == 0 && std::fabs(rhs.x - x) > 2 * std::numeric_limits<double>::round_error())
- return false;
- if(std::fabs(rhs.x/x - 1.0) > 2 * std::numeric_limits<double>::round_error())
+ if(std::abs( boost::math::float_distance(x, rhs.x)) > 1)
         return false;
     if(0 != y.compare(rhs.y))
         return false;

Modified: trunk/libs/serialization/example/demo_dll_a.ipp
==============================================================================
--- trunk/libs/serialization/example/demo_dll_a.ipp Mon Oct 28 11:36:41 2013 (r86500)
+++ trunk/libs/serialization/example/demo_dll_a.ipp 2013-10-28 11:39:01 EDT (Mon, 28 Oct 2013) (r86501)
@@ -244,14 +244,10 @@
     if(u != rhs.u)
         return false;
     if(v != rhs.v)
- return false;
- if(w == 0 && std::fabs(rhs.w) > std::numeric_limits<float>::epsilon())
- return false;
- if(std::fabs(rhs.w/w - 1.0) > std::numeric_limits<float>::epsilon())
         return false;
- if(x == 0 && std::fabs(rhs.x - x) > std::numeric_limits<float>::epsilon())
+ if(std::abs( boost::math::float_distance(w, rhs.w)) > 1)
         return false;
- if(std::fabs(rhs.x/x - 1.0) > std::numeric_limits<float>::epsilon())
+ if(std::abs( boost::math::float_distance(x, rhs.x)) > 1)
         return false;
     if(0 != y.compare(rhs.y))
         return false;

Modified: trunk/libs/serialization/example/demo_dll_b.hpp
==============================================================================
--- trunk/libs/serialization/example/demo_dll_b.hpp Mon Oct 28 11:36:41 2013 (r86500)
+++ trunk/libs/serialization/example/demo_dll_b.hpp 2013-10-28 11:39:01 EDT (Mon, 28 Oct 2013) (r86501)
@@ -17,6 +17,7 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 
 #include <cstdlib> // for rand()
+#include <boost/math/special_functions/next.hpp>
 
 #include <boost/config.hpp>
 #if defined(BOOST_NO_STDC_NAMESPACE)
@@ -104,8 +105,8 @@
         && t == rhs.t
         && u == rhs.u
         && v == rhs.v
- && std::fabs(w - rhs.w) <= std::numeric_limits<float>::round_error()
- && std::fabs(x - rhs.x) <= std::numeric_limits<float>::round_error()
+ && std::abs( boost::math::float_distance(w, rhs.w)) < 2
+ && std::abs( boost::math::float_distance(x, rhs.x)) < 2
     ;
 }
 

Modified: trunk/libs/serialization/example/demo_dll_b.ipp
==============================================================================
--- trunk/libs/serialization/example/demo_dll_b.ipp Mon Oct 28 11:36:41 2013 (r86500)
+++ trunk/libs/serialization/example/demo_dll_b.ipp 2013-10-28 11:39:01 EDT (Mon, 28 Oct 2013) (r86501)
@@ -104,8 +104,8 @@
         && t == rhs.t
         && u == rhs.u
         && v == rhs.v
- && std::fabs(w - rhs.w) <= std::numeric_limits<float>::round_error()
- && std::fabs(x - rhs.x) <= std::numeric_limits<float>::round_error()
+ && std::abs( boost::math::float_distance(w, rhs.w)) < 2
+ && std::abs( boost::math::float_distance(x, rhs.x)) < 2
     ;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk