Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77156 - sandbox/big_number/boost/multiprecision
From: john_at_[hidden]
Date: 2012-03-02 13:41:33


Author: johnmaddock
Date: 2012-03-02 13:41:33 EST (Fri, 02 Mar 2012)
New Revision: 77156
URL: http://svn.boost.org/trac/boost/changeset/77156

Log:
Improve subtract performance.
Text files modified:
   sandbox/big_number/boost/multiprecision/cpp_int.hpp | 10 ++++------
   1 files changed, 4 insertions(+), 6 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/cpp_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_int.hpp 2012-03-02 13:41:33 EST (Fri, 02 Mar 2012)
@@ -760,22 +760,20 @@
    }
    
    unsigned i = 0;
- BOOST_STATIC_CONSTANT(double_limb_type, borrow_value = static_cast<double_limb_type>(cpp_int_backend<InternalLimbs, Allocator>::max_limb_value) + 1);
    // First where a and b overlap:
    while(i < m)
    {
- borrow += pb[i];
- borrow = (borrow_value + static_cast<double_limb_type>(pa[i])) - borrow;
+ borrow = static_cast<double_limb_type>(pa[i]) - static_cast<double_limb_type>(pb[i]) - borrow;
       pr[i] = static_cast<limb_type>(borrow);
- borrow = borrow & borrow_value ? 0 : 1;
+ borrow = (borrow >> cpp_int_backend<InternalLimbs, Allocator>::limb_bits) & 1u;
       ++i;
    }
    // Now where only a has digits, only as long as we've borrowed:
    while(borrow && (i < x))
    {
- borrow = (borrow_value + static_cast<double_limb_type>(pa[i])) - borrow;
+ borrow = static_cast<double_limb_type>(pa[i]) - borrow;
       pr[i] = static_cast<limb_type>(borrow);
- borrow = borrow & borrow_value ? 0 : 1;
+ borrow = (borrow >> cpp_int_backend<InternalLimbs, Allocator>::limb_bits) & 1u;
       ++i;
    }
    // Any remaining digits are the same as those in pa:


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