correct rounding

fix memory leak for constructor failure in load_construct_data
fix another bug in loading pointers

[SVN r86487]
This commit is contained in:
Robert Ramey
2013-10-27 20:50:26 +00:00
parent aad837cf20
commit 599c58825b
10 changed files with 26 additions and 24 deletions

View File

@@ -148,13 +148,13 @@ bool A::operator==(const A &rhs) const
return false;
if(v != rhs.v)
return false;
if(w == 0 && std::fabs(rhs.w) > std::numeric_limits<float>::epsilon())
if(w == 0 && std::fabs(rhs.w) > 2 * std::numeric_limits<float>::round_error())
return false;
if(std::fabs(rhs.w/w - 1.0) > std::numeric_limits<float>::epsilon())
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) > std::numeric_limits<float>::epsilon())
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) > std::numeric_limits<float>::epsilon())
if(std::fabs(rhs.x/x - 1.0) > 2 * std::numeric_limits<double>::round_error())
return false;
if(0 != y.compare(rhs.y))
return false;

View File

@@ -10,7 +10,7 @@
// which use wchar_t as 2 byte objects will emit warnings. These should be
// ignored.
#include <algorithm>
#include <algorithm> // std::copy
#include <fstream>
#include <iostream>
#include <iterator>

View File

@@ -68,8 +68,8 @@ int test_main( int /* argc */, char* /* argv */[] )
ia >> boost::serialization::make_nvp("adoublecomplex", b1);
}
BOOST_CHECK(std::abs(a-a1) <= 2.*std::numeric_limits<float>::round_error());
BOOST_CHECK(std::abs(b-b1) <= 2.*std::numeric_limits<double>::round_error());
BOOST_CHECK(std::abs(a-a1) <= (2 * std::numeric_limits<float>::round_error()));
BOOST_CHECK(std::abs(b-b1) <= (2 * std::numeric_limits<double>::round_error()));
std::remove(testfile);
return EXIT_SUCCESS;

View File

@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
#include <algorithm> // std::copy
#include <vector>
#include <cstdlib> // for rand
#include <functional>

View File

@@ -8,7 +8,7 @@
// should pass compilation and execution
#include <algorithm>
#include <algorithm> // std::copy
#include <vector>
#include <fstream>
#include <cstddef> // size_t, NULL

View File

@@ -12,7 +12,7 @@
#include <cstdio> // remove
#include <fstream>
#include <algorithm>
#include <algorithm> // std::copy
#include <vector>
#include <boost/config.hpp>

View File

@@ -52,16 +52,16 @@ bool A::check_equal(const A &rhs) const
BOOST_CHECK_EQUAL(l, rhs.l);
BOOST_CHECK(!(
w == 0
&& std::fabs(rhs.w) > std::numeric_limits<float>::epsilon()
&& std::fabs(rhs.w) > std::numeric_limits<float>::round_error()
));
BOOST_CHECK(!(
std::fabs(rhs.w/w - 1.0) > std::numeric_limits<float>::epsilon()
std::fabs(rhs.w/w - 1.0) > 2.0 * std::numeric_limits<float>::round_error()
));
BOOST_CHECK(!(
x == 0 && std::fabs(rhs.x - x) > std::numeric_limits<float>::epsilon()
x == 0 && std::fabs(rhs.x - x) > 2.0 * std::numeric_limits<double>::round_error()
));
BOOST_CHECK(!(
std::fabs(rhs.x/x - 1.0) > std::numeric_limits<float>::epsilon()
std::fabs(rhs.x/x - 1.0) > 2.0 * std::numeric_limits<double>::round_error()
));
BOOST_CHECK(!(0 != y.compare(rhs.y)));
#ifndef BOOST_NO_STD_WSTRING

View File

@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
#include <algorithm> // std::copy
#include <fstream>
#include <iostream>
#include <iterator>