|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86340 - in sandbox/multiprecision.cpp_bin_float: boost/multiprecision libs/multiprecision/test
From: john_at_[hidden]
Date: 2013-10-17 11:13:20
Author: johnmaddock
Date: 2013-10-17 11:13:20 EDT (Thu, 17 Oct 2013)
New Revision: 86340
URL: http://svn.boost.org/trac/boost/changeset/86340
Log:
Fix type of underlying integer to work with allocators.
Fix convert_to routines to handle very large bit counts.
Text files modified:
sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp | 12 ++++++++----
sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp | 5 +++--
2 files changed, 11 insertions(+), 6 deletions(-)
Modified: sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp Thu Oct 17 11:11:13 2013 (r86339)
+++ sandbox/multiprecision.cpp_bin_float/boost/multiprecision/cpp_bin_float.hpp 2013-10-17 11:13:20 EDT (Thu, 17 Oct 2013) (r86340)
@@ -29,8 +29,8 @@
{
public:
static const unsigned bit_count = DigitBase == digit_base_2 ? Digits : (Digits * 1000uL) / 301uL + ((Digits * 1000uL) % 301 ? 2u : 1u);
- typedef cpp_int_backend<bit_count, bit_count, unsigned_magnitude, unchecked, Allocator> rep_type;
- typedef cpp_int_backend<2 * bit_count, 2 * bit_count, unsigned_magnitude, unchecked, Allocator> double_rep_type;
+ typedef cpp_int_backend<is_void<Allocator>::value ? bit_count : 0, bit_count, is_void<Allocator>::value ? unsigned_magnitude : signed_magnitude, unchecked, Allocator> rep_type;
+ typedef cpp_int_backend<is_void<Allocator>::value ? 2 * bit_count : 0, 2 * bit_count, is_void<Allocator>::value ? unsigned_magnitude : signed_magnitude, unchecked, Allocator> double_rep_type;
typedef typename rep_type::signed_types signed_types;
typedef typename rep_type::unsigned_types unsigned_types;
@@ -1070,8 +1070,12 @@
}
typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type e = arg.exponent();
e -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1;
- eval_convert_to(res, arg.bits());
- *res = std::ldexp(*res, e);
+ *res = std::ldexp(static_cast<long double>(*arg.bits().limbs()), e);
+ for(unsigned i = 1; i < arg.bits().size(); ++i)
+ {
+ e += sizeof(*arg.bits().limbs()) * CHAR_BIT;
+ *res += std::ldexp(static_cast<long double>(arg.bits().limbs()[i]), e);
+ }
if(arg.sign())
*res = -*res;
}
Modified: sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp
==============================================================================
--- sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp Thu Oct 17 11:11:13 2013 (r86339)
+++ sandbox/multiprecision.cpp_bin_float/libs/multiprecision/test/test_arithmetic_cpp_bin_float_1.cpp 2013-10-17 11:13:20 EDT (Thu, 17 Oct 2013) (r86340)
@@ -14,14 +14,15 @@
template <unsigned D>
struct related_type<boost::multiprecision::number< boost::multiprecision::cpp_bin_float<D> > >
{
- typedef boost::multiprecision::number< boost::multiprecision::cpp_bin_float<D/2> > type;
+ typedef boost::multiprecision::number< boost::multiprecision::cpp_bin_float<(D / 2 > std::numeric_limits<long double>::digits10 ? D / 2 : D)> > type;
};
int main()
{
//test<boost::multiprecision::cpp_bin_float_50>();
//test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<21> > >();
- test<boost::multiprecision::float80_t>();
+ test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<1000, boost::multiprecision::digit_base_10, std::allocator<void> > > >();
+ //test<boost::multiprecision::float128_t>();
return boost::report_errors();
}
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