mirror of
https://github.com/boostorg/functional.git
synced 2025-08-02 05:54:29 +02:00
Remove optimization which causes 0.5 to hash to 0. Refs #4038.
I have an internal requirement the 0 hashes to 0, a better solution might be to remove that, put the optimization back and hash 0 to another value. Or alternatively, use the main combine function instead. [SVN r60805]
This commit is contained in:
@@ -79,6 +79,11 @@ void float_tests(char const* name, T* = 0)
|
|||||||
BOOST_TEST(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero));
|
BOOST_TEST(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BOOST_TEST(x1(zero) != x1(0.5));
|
||||||
|
BOOST_TEST(x1(minus_zero) != x1(0.5));
|
||||||
|
BOOST_TEST(x1(0.5) != x1(-0.5));
|
||||||
|
BOOST_TEST(x1(1) != x1(-1));
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Doing anything with infinity causes borland to crash.
|
// Doing anything with infinity causes borland to crash.
|
||||||
@@ -176,6 +181,12 @@ void float_tests(char const* name, T* = 0)
|
|||||||
BOOST_TEST(half_max != three_quarter_max);
|
BOOST_TEST(half_max != three_quarter_max);
|
||||||
BOOST_TEST(quarter_max != three_quarter_max);
|
BOOST_TEST(quarter_max != three_quarter_max);
|
||||||
|
|
||||||
|
BOOST_TEST(max != -max);
|
||||||
|
BOOST_TEST(half_max != -half_max);
|
||||||
|
BOOST_TEST(quarter_max != -quarter_max);
|
||||||
|
BOOST_TEST(three_quarter_max != -three_quarter_max);
|
||||||
|
|
||||||
|
|
||||||
#if defined(TEST_EXTENSIONS)
|
#if defined(TEST_EXTENSIONS)
|
||||||
BOOST_TEST(x1(max) == HASH_NAMESPACE::hash_value(max));
|
BOOST_TEST(x1(max) == HASH_NAMESPACE::hash_value(max));
|
||||||
BOOST_TEST(x1(half_max) == HASH_NAMESPACE::hash_value(half_max));
|
BOOST_TEST(x1(half_max) == HASH_NAMESPACE::hash_value(half_max));
|
||||||
@@ -197,6 +208,12 @@ void float_tests(char const* name, T* = 0)
|
|||||||
BOOST_TEST(x1(half_max) != x1(three_quarter_max));
|
BOOST_TEST(x1(half_max) != x1(three_quarter_max));
|
||||||
BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max));
|
BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max));
|
||||||
|
|
||||||
|
BOOST_TEST(x1(max) != x1(-max));
|
||||||
|
BOOST_TEST(x1(half_max) != x1(-half_max));
|
||||||
|
BOOST_TEST(x1(quarter_max) != x1(-quarter_max));
|
||||||
|
BOOST_TEST(x1(three_quarter_max) != x1(-three_quarter_max));
|
||||||
|
|
||||||
|
|
||||||
// Intel with gcc stdlib sometimes segfaults on calls to asin and acos.
|
// Intel with gcc stdlib sometimes segfaults on calls to asin and acos.
|
||||||
#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \
|
#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \
|
||||||
defined(__ICC) || defined(__ECC)) && \
|
defined(__ICC) || defined(__ECC)) && \
|
||||||
|
@@ -51,17 +51,15 @@ namespace boost
|
|||||||
limits<T>::min_exponent;
|
limits<T>::min_exponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result of frexp is always between 0.5 and 1, so its
|
v = ldexp(v, limits<std::size_t>::digits);
|
||||||
// top bit will always be 1. Subtract by 0.5 to remove that.
|
|
||||||
v -= T(0.5);
|
|
||||||
v = ldexp(v, limits<std::size_t>::digits + 1);
|
|
||||||
std::size_t seed = static_cast<std::size_t>(v);
|
std::size_t seed = static_cast<std::size_t>(v);
|
||||||
v -= seed;
|
v -= seed;
|
||||||
|
|
||||||
// ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;
|
// ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;
|
||||||
std::size_t const length
|
std::size_t const length
|
||||||
= (limits<T>::digits *
|
= (limits<T>::digits *
|
||||||
boost::static_log2<limits<T>::radix>::value - 1)
|
boost::static_log2<limits<T>::radix>::value
|
||||||
|
+ limits<std::size_t>::digits - 1)
|
||||||
/ limits<std::size_t>::digits;
|
/ limits<std::size_t>::digits;
|
||||||
|
|
||||||
for(std::size_t i = 0; i != length; ++i)
|
for(std::size_t i = 0; i != length; ++i)
|
||||||
|
Reference in New Issue
Block a user