Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86339 - in trunk/boost/multiprecision: . detail detail/functions
From: john_at_[hidden]
Date: 2013-10-17 11:11:14


Author: johnmaddock
Date: 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013)
New Revision: 86339
URL: http://svn.boost.org/trac/boost/changeset/86339

Log:
Fix type of cast target when casting to allocator.
Add additional type of argument to frexp/ldexp.
Template integer types in float IO conversion routines.
Improve termination condition in asin code.
Fix some compiler errors that can occur in conversion routines.

Text files modified:
   trunk/boost/multiprecision/cpp_int.hpp | 4 ++--
   trunk/boost/multiprecision/detail/default_ops.hpp | 6 ++++--
   trunk/boost/multiprecision/detail/float_string_cvt.hpp | 3 ++-
   trunk/boost/multiprecision/detail/functions/pow.hpp | 2 +-
   trunk/boost/multiprecision/detail/functions/trig.hpp | 8 +++++++-
   trunk/boost/multiprecision/detail/generic_interconvert.hpp | 6 +++---
   6 files changed, 19 insertions(+), 10 deletions(-)

Modified: trunk/boost/multiprecision/cpp_int.hpp
==============================================================================
--- trunk/boost/multiprecision/cpp_int.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/cpp_int.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -283,7 +283,7 @@
    }
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    cpp_int_base(cpp_int_base&& o)
- : allocator_type(static_cast<Allocator&&>(o)), m_limbs(o.m_limbs), m_sign(o.m_sign), m_internal(o.m_internal)
+ : allocator_type(static_cast<allocator_type&&>(o)), m_limbs(o.m_limbs), m_sign(o.m_sign), m_internal(o.m_internal)
    {
       if(m_internal)
       {
@@ -300,7 +300,7 @@
    {
       if(!m_internal)
          allocator().deallocate(m_data.ld.data, m_data.ld.capacity);
- *static_cast<Allocator*>(this) = static_cast<Allocator&&>(o);
+ *static_cast<allocator_type*>(this) = static_cast<allocator_type&&>(o);
       m_limbs = o.m_limbs;
       m_sign = o.m_sign;
       m_internal = o.m_internal;

Modified: trunk/boost/multiprecision/detail/default_ops.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/default_ops.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/detail/default_ops.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -2007,8 +2007,10 @@
 UNARY_OP_FUNCTOR(sinh, number_kind_floating_point)
 UNARY_OP_FUNCTOR(tanh, number_kind_floating_point)
 
-HETERO_BINARY_OP_FUNCTOR(ldexp, int, number_kind_floating_point)
-HETERO_BINARY_OP_FUNCTOR(frexp, int*, number_kind_floating_point)
+HETERO_BINARY_OP_FUNCTOR(ldexp, short, number_kind_floating_point)
+HETERO_BINARY_OP_FUNCTOR(frexp, short*, number_kind_floating_point)
+HETERO_BINARY_OP_FUNCTOR_B(ldexp, int, number_kind_floating_point)
+HETERO_BINARY_OP_FUNCTOR_B(frexp, int*, number_kind_floating_point)
 HETERO_BINARY_OP_FUNCTOR_B(ldexp, long, number_kind_floating_point)
 HETERO_BINARY_OP_FUNCTOR_B(frexp, long*, number_kind_floating_point)
 HETERO_BINARY_OP_FUNCTOR_B(ldexp, long long, number_kind_floating_point)

Modified: trunk/boost/multiprecision/detail/float_string_cvt.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/float_string_cvt.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/detail/float_string_cvt.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -16,7 +16,8 @@
 
 namespace boost{ namespace multiprecision{ namespace detail{
 
-inline void round_string_up_at(std::string& s, int pos, int& expon)
+template <class I>
+inline void round_string_up_at(std::string& s, int pos, I& expon)
 {
    //
    // Rounds up a string representation of a number at pos:

Modified: trunk/boost/multiprecision/detail/functions/pow.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/functions/pow.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/detail/functions/pow.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -227,7 +227,7 @@
       xx.negate();
 
    // Check the range of the argument.
- static const canonical_exp_type maximum_arg_for_exp = std::numeric_limits<number<T, et_on> >::max_exponent == 0 ? (std::numeric_limits<long>::max)() : std::numeric_limits<number<T, et_on> >::max_exponent;
+ static const canonical_exp_type maximum_arg_for_exp = std::numeric_limits<number<T, et_on> >::max_exponent == 0 ? static_cast<canonical_exp_type>((std::numeric_limits<long>::max)()) : std::numeric_limits<number<T, et_on> >::max_exponent;
 
    if(xx.compare(maximum_arg_for_exp) >= 0)
    {

Modified: trunk/boost/multiprecision/detail/functions/trig.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/functions/trig.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/detail/functions/trig.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -488,8 +488,11 @@
 
    result = fp_type(std::asin(dd));
 
+ unsigned current_digits = std::numeric_limits<double>::digits - 5;
+ unsigned target_precision = boost::multiprecision::detail::digits2<number<T, et_on> >::value;
+
    // Newton-Raphson iteration
- while(true)
+ while(current_digits < target_precision)
    {
       T s, c;
       eval_sin(s, result);
@@ -498,6 +501,8 @@
       eval_divide(s, c);
       eval_subtract(result, s);
 
+ current_digits *= 2;
+ /*
       T lim;
       eval_ldexp(lim, result, 1 - boost::multiprecision::detail::digits2<number<T, et_on> >::value);
       if(eval_get_sign(s) < 0)
@@ -506,6 +511,7 @@
          lim.negate();
       if(lim.compare(s) >= 0)
          break;
+ */
    }
    if(b_neg)
       result.negate();

Modified: trunk/boost/multiprecision/detail/generic_interconvert.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/generic_interconvert.hpp Thu Oct 17 02:21:28 2013 (r86338)
+++ trunk/boost/multiprecision/detail/generic_interconvert.hpp 2013-10-17 11:11:13 EDT (Thu, 17 Oct 2013) (r86339)
@@ -143,12 +143,12 @@
    }
    else if(c == FP_NAN)
    {
- to = "nan";
+ to = static_cast<const char*>("nan");
       return;
    }
    else if(c == FP_INFINITE)
    {
- to = "inf";
+ to = static_cast<const char*>("inf");
       if(eval_get_sign(from) < 0)
          to.negate();
       return;
@@ -177,7 +177,7 @@
    typedef typename To::exponent_type to_exponent;
    if((e > (std::numeric_limits<to_exponent>::max)()) || (e < (std::numeric_limits<to_exponent>::min)()))
    {
- to = "inf";
+ to = static_cast<const char*>("inf");
       if(eval_get_sign(from) < 0)
          to.negate();
       return;


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