Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76550 - in sandbox/big_number/boost/multiprecision: . concepts
From: john_at_[hidden]
Date: 2012-01-17 08:06:35


Author: johnmaddock
Date: 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
New Revision: 76550
URL: http://svn.boost.org/trac/boost/changeset/76550

Log:
Rejig intmax_t and long long usage to be much more consistent.
Text files modified:
   sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp | 8 ++++----
   sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp | 16 ++++++++--------
   sandbox/big_number/boost/multiprecision/cpp_float.hpp | 6 +++---
   sandbox/big_number/boost/multiprecision/fixed_int.hpp | 23 +++++++++++------------
   sandbox/big_number/boost/multiprecision/gmp.hpp | 24 ++++++++++++------------
   sandbox/big_number/boost/multiprecision/mpfr.hpp | 10 +++++-----
   sandbox/big_number/boost/multiprecision/tommath.hpp | 8 ++++----
   7 files changed, 47 insertions(+), 48 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp (original)
+++ sandbox/big_number/boost/multiprecision/arithmetic_backend.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -39,12 +39,12 @@
       m_value = o.m_value;
       return *this;
    }
- arithmetic_backend& operator = (boost::uintmax_t i)
+ arithmetic_backend& operator = (unsigned long long i)
    {
       m_value = i;
       return *this;
    }
- arithmetic_backend& operator = (boost::intmax_t i)
+ arithmetic_backend& operator = (long long i)
    {
       m_value = i;
       return *this;
@@ -78,11 +78,11 @@
    {
       return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0);
    }
- int compare(boost::intmax_t i)const
+ int compare(long long i)const
    {
       return m_value > i ? 1 : (m_value < i ? -1 : 0);
    }
- int compare(boost::uintmax_t i)const
+ int compare(unsigned long long i)const
    {
       return m_value > i ? 1 : (m_value < i ? -1 : 0);
    }

Modified: sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp (original)
+++ sandbox/big_number/boost/multiprecision/concepts/mp_number_architypes.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -45,13 +45,13 @@
       std::cout << "Assignment (" << m_value << ")" << std::endl;
       return *this;
    }
- mp_number_backend_float_architype& operator = (boost::uintmax_t i)
+ mp_number_backend_float_architype& operator = (unsigned long long i)
    {
       m_value = i;
       std::cout << "UInt Assignment (" << i << ")" << std::endl;
       return *this;
    }
- mp_number_backend_float_architype& operator = (boost::intmax_t i)
+ mp_number_backend_float_architype& operator = (long long i)
    {
       m_value = i;
       std::cout << "Int Assignment (" << i << ")" << std::endl;
@@ -104,12 +104,12 @@
       std::cout << "Comparison" << std::endl;
       return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0);
    }
- int compare(boost::intmax_t i)const
+ int compare(long long i)const
    {
       std::cout << "Comparison with int" << std::endl;
       return m_value > i ? 1 : (m_value < i ? -1 : 0);
    }
- int compare(boost::uintmax_t i)const
+ int compare(unsigned long long i)const
    {
       std::cout << "Comparison with unsigned" << std::endl;
       return m_value > i ? 1 : (m_value < i ? -1 : 0);
@@ -143,13 +143,13 @@
    result.m_value /= o.m_value;
 }
 
-inline void convert_to(boost::uintmax_t* result, const mp_number_backend_float_architype& val)
+inline void convert_to(unsigned long long* result, const mp_number_backend_float_architype& val)
 {
- *result = static_cast<boost::uintmax_t>(val.m_value);
+ *result = static_cast<unsigned long long>(val.m_value);
 }
-inline void convert_to(boost::intmax_t* result, const mp_number_backend_float_architype& val)
+inline void convert_to(long long* result, const mp_number_backend_float_architype& val)
 {
- *result = static_cast<boost::intmax_t>(val.m_value);
+ *result = static_cast<long long>(val.m_value);
 }
 inline void convert_to(long double* result, mp_number_backend_float_architype& val)
 {

Modified: sandbox/big_number/boost/multiprecision/cpp_float.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_float.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_float.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -1815,7 +1815,7 @@
       )
    {
       // Remove the exponent part from the string.
- exp = boost::lexical_cast<boost::int64_t>(static_cast<const char* const>(str.c_str() + (pos + 1u)));
+ exp = boost::lexical_cast<boost::int64_t>(static_cast<const char*>(str.c_str() + (pos + 1u)));
       str = str.substr(static_cast<std::size_t>(0u), pos);
    }
 
@@ -2059,7 +2059,7 @@
 }
 
 template <unsigned Digits10>
-cpp_float<Digits10>::cpp_float(const double mantissa, const boost::int64_t exponent)
+cpp_float<Digits10>::cpp_float(const double mantissa, const long long exponent)
  : data (),
    exp (static_cast<boost::int64_t>(0)),
    neg (false),
@@ -2245,7 +2245,7 @@
 }
 
 template <unsigned Digits10>
-cpp_float<Digits10> cpp_float<Digits10>::pow2(const boost::int64_t p)
+cpp_float<Digits10> cpp_float<Digits10>::pow2(const long long p)
 {
    // Create a static const table of p^2 for -128 < p < +128.
    // Note: The size of this table must be odd-numbered and

Modified: sandbox/big_number/boost/multiprecision/fixed_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/fixed_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/fixed_int.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -26,10 +26,9 @@
 struct fixed_int
 {
    typedef mpl::list<signed_limb_type, signed_double_limb_type> signed_types;
- typedef mpl::list<limb_type, double_limb_type> unsigned_types;
- typedef mpl::list<long double> float_types;
+ typedef mpl::list<limb_type, double_limb_type> unsigned_types;
+ typedef mpl::list<long double> float_types;
 
- typedef limb_type limb_type;
    BOOST_STATIC_CONSTANT(unsigned, limb_bits = sizeof(limb_type) * CHAR_BIT);
    BOOST_STATIC_CONSTANT(unsigned, limb_count = Bits / limb_bits + (Bits % limb_bits ? 1 : 0));
    BOOST_STATIC_CONSTANT(limb_type, max_limb_value = ~static_cast<limb_type>(0u));
@@ -365,7 +364,7 @@
    for(int i = fixed_int<Bits, Signed>::limb_count - 1; i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(a.data()[i]) + static_cast<double_limb_type>(b.data()[i]);
- result.data()[i] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i] = static_cast<limb_type>(carry);
       carry >>= fixed_int<Bits, Signed>::limb_bits;
    }
    result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
@@ -379,7 +378,7 @@
    for(int i = fixed_int<Bits, Signed>::limb_count - 1; carry && i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(result.data()[i]);
- result.data()[i] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i] = static_cast<limb_type>(carry);
       carry >>= fixed_int<Bits, Signed>::limb_bits;
    }
    result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
@@ -399,12 +398,12 @@
    // This is the same code as for addition, with the twist that we negate o "on the fly":
    double_limb_type carry = static_cast<double_limb_type>(result.data()[fixed_int<Bits, Signed>::limb_count - 1])
       + 1uLL + static_cast<double_limb_type>(~o);
- result.data()[fixed_int<Bits, Signed>::limb_count - 1] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[fixed_int<Bits, Signed>::limb_count - 1] = static_cast<limb_type>(carry);
    carry >>= fixed_int<Bits, Signed>::limb_bits;
    for(int i = fixed_int<Bits, Signed>::limb_count - 2; i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(result.data()[i]) + 0xFFFFFFFF;
- result.data()[i] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i] = static_cast<limb_type>(carry);
       carry >>= fixed_int<Bits, Signed>::limb_bits;
    }
    result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
@@ -452,7 +451,7 @@
    for(int i = fixed_int<Bits, Signed>::limb_count - 1; i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(a.data()[i]) + static_cast<double_limb_type>(~b.data()[i]);
- result.data()[i] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i] = static_cast<limb_type>(carry);
       carry >>= fixed_int<Bits, Signed>::limb_bits;
    }
    result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
@@ -483,7 +482,7 @@
       {
          carry += static_cast<double_limb_type>(a.data()[i]) * static_cast<double_limb_type>(b.data()[j]);
          carry += result.data()[i + j + 1 - fixed_int<Bits, Signed>::limb_count];
- result.data()[i + j + 1 - fixed_int<Bits, Signed>::limb_count] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i + j + 1 - fixed_int<Bits, Signed>::limb_count] = static_cast<limb_type>(carry);
          carry >>= fixed_int<Bits, Signed>::limb_bits;
       }
       carry = 0;
@@ -504,7 +503,7 @@
    for(int i = fixed_int<Bits, Signed>::limb_count - 1; i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(result.data()[i]) * static_cast<double_limb_type>(a);
- result.data()[i] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ result.data()[i] = static_cast<limb_type>(carry);
       carry >>= fixed_int<Bits, Signed>::limb_bits;
    }
    result.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
@@ -761,7 +760,7 @@
          a = (r_order < fixed_int<Bits, Signed>::limb_count - 1) ? (static_cast<double_limb_type>(r.data()[r_order]) << fixed_int<Bits, Signed>::limb_bits) | r.data()[r_order + 1] : r.data()[r_order];
          b = (y_order < fixed_int<Bits, Signed>::limb_count - 1) ? (static_cast<double_limb_type>(y.data()[y_order]) << fixed_int<Bits, Signed>::limb_bits) | y.data()[y_order + 1] : (static_cast<double_limb_type>(y.data()[y_order]) << fixed_int<Bits, Signed>::limb_bits);
          v = a / b;
- guess = static_cast<typename fixed_int<Bits, Signed>::limb_type>(v);
+ guess = static_cast<limb_type>(v);
          //guess = r.data()[r_order] / y.data()[y_order];
       }
       //
@@ -784,7 +783,7 @@
       for(int i = fixed_int<Bits, Signed>::limb_count - 1; i >= static_cast<int>(shift); --i)
       {
          carry += static_cast<double_limb_type>(y.data()[i]) * static_cast<double_limb_type>(guess);
- t.data()[i - shift] = static_cast<typename fixed_int<Bits, Signed>::limb_type>(carry);
+ t.data()[i - shift] = static_cast<limb_type>(carry);
          carry >>= fixed_int<Bits, Signed>::limb_bits;
       }
       t.data()[0] &= fixed_int<Bits, Signed>::upper_limb_mask;

Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -63,9 +63,9 @@
       return *this;
    }
 #endif
- gmp_float_imp& operator = (boost::uintmax_t i)
+ gmp_float_imp& operator = (unsigned long long i)
    {
- boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpf_t t;
       mpf_init2(t, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
@@ -82,11 +82,11 @@
       mpf_clear(t);
       return *this;
    }
- gmp_float_imp& operator = (boost::intmax_t i)
+ gmp_float_imp& operator = (long long i)
    {
       BOOST_MP_USING_ABS
       bool neg = i < 0;
- *this = static_cast<boost::uintmax_t>(abs(i));
+ *this = static_cast<unsigned long long>(abs(i));
       if(neg)
          mpf_neg(m_data, m_data);
       return *this;
@@ -891,9 +891,9 @@
       mpz_set(m_data, o.m_data);
       return *this;
    }
- gmp_int& operator = (boost::uintmax_t i)
+ gmp_int& operator = (unsigned long long i)
    {
- boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpz_t t;
       mpz_init(m_data);
@@ -910,11 +910,11 @@
       mpz_clear(t);
       return *this;
    }
- gmp_int& operator = (boost::intmax_t i)
+ gmp_int& operator = (long long i)
    {
       BOOST_MP_USING_ABS
       bool neg = i < 0;
- *this = static_cast<boost::uintmax_t>(abs(i));
+ *this = static_cast<unsigned long long>(abs(i));
       if(neg)
          mpz_neg(m_data, m_data);
       return *this;
@@ -1430,9 +1430,9 @@
       mpq_set(m_data, o.m_data);
       return *this;
    }
- gmp_rational& operator = (boost::uintmax_t i)
+ gmp_rational& operator = (unsigned long long i)
    {
- boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpq_t t;
       mpq_init(m_data);
@@ -1449,11 +1449,11 @@
       mpq_clear(t);
       return *this;
    }
- gmp_rational& operator = (boost::intmax_t i)
+ gmp_rational& operator = (long long i)
    {
       BOOST_MP_USING_ABS
       bool neg = i < 0;
- *this = static_cast<boost::uintmax_t>(abs(i));
+ *this = static_cast<unsigned long long>(abs(i));
       if(neg)
          mpq_neg(m_data, m_data);
       return *this;

Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -59,12 +59,12 @@
       return *this;
    }
 #endif
- mpfr_float_imp& operator = (boost::uintmax_t i)
+ mpfr_float_imp& operator = (unsigned long long i)
    {
- boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpfr_t t;
- mpfr_init2(t, (std::max)(static_cast<unsigned>(std::numeric_limits<boost::uintmax_t>::digits), static_cast<unsigned>(((digits10 + 1) * 1000L) / 301L)));
+ mpfr_init2(t, (std::max)(static_cast<unsigned>(std::numeric_limits<unsigned long long>::digits), static_cast<unsigned>(((digits10 + 1) * 1000L) / 301L)));
       mpfr_set_ui(m_data, 0, GMP_RNDN);
       while(i)
       {
@@ -78,11 +78,11 @@
       mpfr_clear(t);
       return *this;
    }
- mpfr_float_imp& operator = (boost::intmax_t i)
+ mpfr_float_imp& operator = (long long i)
    {
       BOOST_MP_USING_ABS
       bool neg = i < 0;
- *this = static_cast<boost::uintmax_t>(abs(i));
+ *this = static_cast<unsigned long long>(abs(i));
       if(neg)
          mpfr_neg(m_data, m_data, GMP_RNDN);
       return *this;

Modified: sandbox/big_number/boost/multiprecision/tommath.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/tommath.hpp (original)
+++ sandbox/big_number/boost/multiprecision/tommath.hpp 2012-01-17 08:06:33 EST (Tue, 17 Jan 2012)
@@ -50,9 +50,9 @@
       detail::check_tommath_result(mp_copy(const_cast< ::mp_int*>(&o.m_data), &m_data));
       return *this;
    }
- tommath_int& operator = (boost::uintmax_t i)
+ tommath_int& operator = (unsigned long long i)
    {
- boost::uintmax_t mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
+ unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       ::mp_int t;
       detail::check_tommath_result(mp_init(&t));
@@ -69,11 +69,11 @@
       mp_clear(&t);
       return *this;
    }
- tommath_int& operator = (boost::intmax_t i)
+ tommath_int& operator = (long long i)
    {
       BOOST_MP_USING_ABS
       bool neg = i < 0;
- *this = static_cast<boost::uintmax_t>(abs(i));
+ *this = static_cast<unsigned long long>(abs(i));
       if(neg)
          detail::check_tommath_result(mp_neg(&m_data, &m_data));
       return *this;


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