summaryrefslogtreecommitdiff
path: root/boost/multiprecision/cpp_dec_float.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:41:18 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:43:11 +0900
commitf763a99a501650eff2c60288aa6f10ef916d769e (patch)
tree02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/multiprecision/cpp_dec_float.hpp
parent5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff)
downloadboost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz
boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2
boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/multiprecision/cpp_dec_float.hpp')
-rw-r--r--boost/multiprecision/cpp_dec_float.hpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/boost/multiprecision/cpp_dec_float.hpp b/boost/multiprecision/cpp_dec_float.hpp
index 057095e2b4..ee14becf5d 100644
--- a/boost/multiprecision/cpp_dec_float.hpp
+++ b/boost/multiprecision/cpp_dec_float.hpp
@@ -25,6 +25,7 @@
#include <boost/array.hpp>
#endif
#include <boost/cstdint.hpp>
+#include <boost/functional/hash_fwd.hpp>
#include <boost/multiprecision/number.hpp>
#include <boost/multiprecision/detail/big_lanczos.hpp>
#include <boost/multiprecision/detail/dynamic_array.hpp>
@@ -257,6 +258,17 @@ public:
cpp_dec_float(const double mantissa, const ExponentType exponent);
+ std::size_t hash()const
+ {
+ std::size_t result = 0;
+ for(int i = 0; i < prec_elem; ++i)
+ boost::hash_combine(result, data[i]);
+ boost::hash_combine(result, exp);
+ boost::hash_combine(result, neg);
+ boost::hash_combine(result, fpclass);
+ return result;
+ }
+
// Specific special values.
static const cpp_dec_float& nan()
{
@@ -948,6 +960,18 @@ cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, Expone
template <unsigned Digits10, class ExponentType, class Allocator>
cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, ExponentType, Allocator>::operator/=(const cpp_dec_float<Digits10, ExponentType, Allocator>& v)
{
+ if(iszero())
+ {
+ if((v.isnan)())
+ {
+ return *this = v;
+ }
+ else if(v.iszero())
+ {
+ return *this = nan();
+ }
+ }
+
const bool u_and_v_are_finite_and_identical = ( (isfinite)()
&& (fpclass == v.fpclass)
&& (exp == v.exp)
@@ -966,14 +990,6 @@ cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, Expone
}
else
{
- if(iszero())
- {
- if((v.isnan)() || v.iszero())
- {
- return *this = v;
- }
- return *this;
- }
cpp_dec_float t(v);
t.calculate_inv();
return operator*=(t);
@@ -2957,6 +2973,12 @@ inline int eval_get_sign(const cpp_dec_float<Digits10, ExponentType, Allocator>&
return val.iszero() ? 0 : val.isneg() ? -1 : 1;
}
+template <unsigned Digits10, class ExponentType, class Allocator>
+inline std::size_t hash_value(const cpp_dec_float<Digits10, ExponentType, Allocator>& val)
+{
+ return val.hash();
+}
+
} // namespace backends
using boost::multiprecision::backends::cpp_dec_float;