From 0b7499f8775e728c4a349933a95fe450c082a338 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 4 Oct 2016 23:14:56 +0200 Subject: Add (non-working yet) Lucas test --- bigint.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bigint.cpp') diff --git a/bigint.cpp b/bigint.cpp index 21c4ab2..9fdafe0 100644 --- a/bigint.cpp +++ b/bigint.cpp @@ -133,8 +133,9 @@ Bigint& Bigint::operator=(slongdigit_t v){ } Bigint& Bigint::operator+=(const Bigint &o){ - if(&o==this){ - return *this=Bigint(*this)+=o; + if(&o==this){ //*this + *this + operator<<=(1); + return *this; } if(sign==1){ if(o.sign==1)add(*this,o); @@ -148,8 +149,10 @@ Bigint& Bigint::operator+=(const Bigint &o){ } Bigint& Bigint::operator-=(const Bigint &o){ - if(&o==this){ - return *this=Bigint(*this)-=o; + if(&o==this){ // *this - *this + sign=1; + digits.clear(); + return *this; } if(sign==1){ if(o.sign==1)subtract(*this,o); -- cgit v1.2.3-70-g09d2